示例基于student表:
创建存储过程:
create or replace procedure read_stu(
t out SYS_REFCURSOR
)
is
begin
open t for select sid,sname from student;
end;
使用存储过程:
declare
t sys_refcursor;
s student%rowtype;
begin
read_stu(t);
loop
fetch
t into s.sid,s.sname;
dbms_output.put_line(s.sid||' '||s.sname);
exit when t%notfound;
end loop;
close t;
end;
返回结果: