ITPub博客

首页 > Linux操作系统 > Linux操作系统 > An example of ref cursor(1)

An example of ref cursor(1)

原创 Linux操作系统 作者:dragondb 时间:2019-05-19 09:48:04 0 删除 编辑
An example of ref cursor

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/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Database limits(8i/9i)
请登录后发表评论 登录
全部评论

注册时间:2003-05-05

  • 博文量
    98
  • 访问量
    94094