declare
c is test%rowtype;
my_cursor cursor;
begin
open my_cursor for select * from test;
loop
fetch my_cursor into c;
exit when my_cursor %notfound;
end loop;
close my_cursor;
end;
c is test%rowtype;
my_cursor cursor;
begin
open my_cursor for select * from test;
loop
fetch my_cursor into c;
exit when my_cursor %notfound;
end loop;
close my_cursor;
end;
不过觉得还是 xjqqxjqq(JAI) 那样写游标的调用方便些啦!
只要数据量不是很具大的,做游标没有什么不好吧?
如:
CREATE OR REPLACE PACKAGE pkg_cursor
as
type return_result is ref cursor;
end;
/
然后在存储过程中调用游标变量,返回select结果集.
create or replace procedure pro_name
(v_cursor out pkg_cursor.reture_result)
begin
open v_cursor for
select * from table_name;
end pro_name;
/