定义了存储过程
CREATE OR REPLACE procedure FTTEST.getproduct2(mycur out sys_refcursor)
as
begin
open mycur for select productid,productname from product;
end;在toad中调用该存储过程
declare
pid varchar2(4);
pname varchar2(8);
rc sys_refcursor;
begin
getproduct2(:rc);
fetch rc into pid,pname;
while rc%found loop
dbms_output.put_line(pid || pname);
end loop;
end;
这样子总是不成功!请教各位问题出在什么地方?
thanks for any suggestion.
CREATE OR REPLACE procedure FTTEST.getproduct2(mycur out sys_refcursor)
as
begin
open mycur for select productid,productname from product;
end;在toad中调用该存储过程
declare
pid varchar2(4);
pname varchar2(8);
rc sys_refcursor;
begin
getproduct2(:rc);
fetch rc into pid,pname;
while rc%found loop
dbms_output.put_line(pid || pname);
end loop;
end;
这样子总是不成功!请教各位问题出在什么地方?
thanks for any suggestion.
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 onSQL> 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>
JACKY
真是佩服,你写的是个死循环!
非常感谢你的指点!