create or replace procedure sumienum(in_gen number)
as sum_num number;
begin
if in_gen='1'
then select count(gender) into sum_num from IT_EMPLOYEES where gender='1';
dbms_output.put_line('Number of Male:'||sum_num);
elsif in_gen='0'
then select count(gender) into sum_num from IT_EMPLOYEES where gender='0';
dbms_output.put_line('Number of Female:'||sum_num);
else
dbms_output.put_line('Input Error:'||in_gen);
end if;
end sumienum;
SQL> execute sumienum('1');
Number of Male:3
PL/SQL 过程已成功完成。
SQL> execute sumienum('0');
Number of Female:2
PL/SQL 过程已成功完成。
SQL> execute sumienum('512');
Input Error:512
PL/SQL 过程已成功完成。