ORACLE_存储过程二

来源:互联网 发布:恒安嘉新怎么样知乎 编辑:程序博客网 时间:2024/04/28 08:31
create or replace  procedure  sum_sal(deptid in emp.deptno%type,sum_salary out number)asbegin   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;beginv_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)asno_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;     


原创粉丝点击