存储过程:
create or replace procedure emp_select(v_no in int,ref_cur out sys_refcursor) AS
BEGIN
open ref_cur for SELECT ename,sal FROM emp where deptno=v_no;
end emp_select;
调用程序:
declare
s_cur SYS_REFCURSOR;
v_no int;
v_name varchar2(10);
v_sal number;
s_sal varchar2(2);
begin
v_no:=&vno;
emp_select(v_no,s_cur);
loop
fetch s_cur into v_name,v_sal;
exit when s_cur%notfound;
case when nvl(v_sal,0)=0 then s_sal:='';
when nvl(v_sal,0)<1000 then s_sal:='低';
when nvl(v_sal,0)<3000 then s_sal:='中';
else s_sal:='高';
end case;
dbms_output.put_line(substr(v_name||' ',1,10)||s_sal);
end loop;
end;