1 create or replace procedure p_adjust_salary(emp_id number,sal in out number)
2 is
3 emp_job varchar2(10);
4 avg_sal number(8,2);
5 begin
6 select job into emp_job from emp where empno=emp_id;
7 select avg(sal) into avg_sal from emp where job=emp_job;
8 sal:=(sal + avg_sal)/2;
9 dbms_output.put_line('now employee salary is:'||sal);
10 exception when others then
11 dbms_output.put_line('table not data hehe');
12* end;
scott>/
2 is
3 emp_job varchar2(10);
4 avg_sal number(8,2);
5 begin
6 select job into emp_job from emp where empno=emp_id;
7 select avg(sal) into avg_sal from emp where job=emp_job;
8 sal:=(sal + avg_sal)/2;
9 dbms_output.put_line('now employee salary is:'||sal);
10 exception when others then
11 dbms_output.put_line('table not data hehe');
12* end;
scott>/
Procedure created.
###在sqlplus中调用in out输入输出参数的存储过程
scott>declare
2 p1 number;
3 p2 number;
4 begin
5 p1:=20;
6 p2:=2;
7 p_adjust_salary(p1,p2);
8 dbms_output.put_line(p2);
9 end;
10 /
table not data hehe
2
PL/SQL procedure successfully completed.
scott>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-666610/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9240380/viewspace-666610/