`

调用oracle10g 存储过程利用sys_refcursor返回结果集

SQL 
阅读更多

SQL> create table test
2 (
3 c1 varchar2(10)
4 )
5 ;

Table created

SQL> insert into test values(1);

1 row inserted

SQL> insert into test values(2);

1 row inserted

SQL> commit;

Commit complete

SQL>
SQL> CREATE OR REPLACE procedure gettest(mycur out sys_refcursor)
2 as
3 begin
4 open mycur for select c1 from test;
5 end;
6 /

Procedure created

SQL> set serveroutput on

SQL> declare
2 c1 varchar2(10);
3 rc sys_refcursor;
4 begin
5 gettest(rc);
6 fetch rc into c1;
7 while rc%found loop
8
9 dbms_output.put_line(c1);
10 fetch rc into c1;
11 end loop;
12 end;
13 /

1
2

PL/SQL procedure successfully completed

SQL>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics