–创建存储过程
set serveroutput on;
–显示错误
show error;
–根据部门编号,输出该部门人数和平均工资
create or replace procedure pro_m(dno in emp.deptno%type)
as
num number(2);
avgsal emp.sal%type;
begin
select count(*),avg(sal) into num, avgsal from emp where deptno=dno;
dbms_output.put_line(num||’ ‘||avgsal);
end;
/
–执行
exec pro_m(10);
–out 返回数据
create or replace procedure pro_m(id in emp.deptno%type, num out number, avgsal out emp.sal%type)
as
begin
select count(*),avg(sal) into num, avgsal from emp where deptno=id;
end;
/
–执行
declare
num number(2);
avgsal emp.sal%type;
begin
pro_m(10, num, avgsal);
dbms_output.put_line(num||’ ‘||avgsal);
end;
/