out:只写。模块能够给这个参数进行赋值,但是这个参数的数值不能被引用。
创建存储过程procedure – test_emp
create or replace procedure test_emp
(
emp_out out sys_refcursor
)
is
begin
open emp_out for select * from emp;
end test_emp;
调用test_emp存储过程,并且得到select查询的结果集
declare
emp_sor sys_refcursor; --使用系统预定义的sys_refcursor
cemp emp%rowtype;
begin
test_emp(emp_sor);
loop
fetch emp_sor into cemp;
exit when emp_sor%notfound; --游标一条一条地遍历记录,当找不到记录时退出
dbms_output.put_line('编号:'||cemp.empno||' 姓名:'||cemp.ename||' 工资:'cemp.sal);
end loop;
close emp_sor;
end;