create or replace procedure sum_sal(deptid in emp.deptno%type,sum_salary out number)as
begin
select sum(sal) into sum_salary from emp where deptno=deptid;
dbms_output.put_line(deptid||'的工資爲'||sum_salary);
exception
when no_data_found then
dbms_output.put_line('你需要的數據不存在');
when others then
dbms_output.put_line('發生其他錯誤');
end;
--調用的方法如下
declare
v_deptid number;
v_sum number;
begin
v_deptid:=30;
sum_sal(v_deptid,v_sum);
dbms_output.put_line('30號部門工資總和'||v_sum);
end;
給指定的員工加薪:create or replace procedure mon_addsel(p_empno in emp.empno%type, p_addsal in emp.comm%type)as
no_result exception;
begin
update emp set comm=p_addsel where empno=p_empno;
if SQL%notfound then
raise no_result;
end if;
dbms_output.put_line(p_empno||'的本月加薪額度爲'||p_addsal);
exception
when no_result then
dbms_output.put_line('該員工不存在!');
when others then
dbms_output.put_line('未知錯誤');
end;