SQL> create table t1(c1 varchar2(20),c2 date);
Table created.
SQL> create or replace package pkg_refcursor_example is
2 type refcursortype is ref cursor;
3 procedure p_refcur (ps in varchar2,pd in date,p_ref_cursor out refcursortype);
4 end pkg_refcursor_example;
5 /
Package created.
SQL> create or replace package body pkg_refcursor_example is
2 procedure p_refcur (ps in varchar2,pd in date,p_ref_cursor out refcursortype) is
3 begin
4 insert into t1(c1,c2)
5 values(ps,pd);
6 commit;
7
8 open p_ref_cursor for
9 select c1,c2
10 from t1;
11 end;
12 end pkg_refcursor_example;
13 /
Package body created.
SQL> var ref_cur refcursor;
SQL> set autop on;
SQL> exec pkg_refcursor_example.p_refcur('aaa',sysdate,:ref_cur);
PL/SQL procedure successfully completed.
C1 C2
-------------------- -------------------
aaa 2007-06-15 17:28:41
SQL> exec pkg_refcursor_example.p_refcur('aaa',sysdate,:ref_cur);
PL/SQL procedure successfully completed.
C1 C2
-------------------- -------------------
aaa 2007-06-15 17:28:41
aaa 2007-06-15 17:28:50
SQL>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/45259/viewspace-134948/ ,如需转载,请注明出处,否则将追究法律责任。