createorreplace package sp_emp_pk as
type sp_emp_cursor is ref cursor;end sp_emp_pk;
/
2、创建返回结果集的存储过程
createor replace PROCEDUREsproc_cursor(deptnum in number,emp_cursor out sp_emp_pk.sp_emp_cursor)isbeginopenemp_cursorforselectename,salfromempwheredeptno=deptnum;end sproc_cursor;
/
3、返回结果集的存储过程的调用
declare
typesp_emp_cursorisrefcursor;
emp_cursor sp_emp_cursor;
--v_empno emp.empno%type:=7839;
v_deptno emp.deptno%type:=10;
v_ename emp.ename%type;
v_sal emp.sal%type;begin
sproc_cursor(v_deptno,emp_cursor);
loop
fetch emp_cursor into v_ename,v_sal;
exit when emp_cursor%notfound;
--sp_pro8(v_empno,v_ename);
dbms_output.put_line(v_ename);
end loop;
--dbms_output.put_line('Hello world');
close emp_cursor;
end;
/