--取简单的游标
declare
cursor sp is
select * from user_tables;
myrecord user_tables%ROWTYPE;
begin
open sp ;
fetch sp into myrecord;
while sp%found loop
dbms_output.put_line(myrecord.table_name);
fetch sp into myrecord;
end loop;
close sp ;
end;
--带参数的游标
declare
cursor sp(rownum number) is
select * from user_tables a where a.NUM_ROWS>=rownum;
myrecord user_tables%ROWTYPE;
begin
open sp(10000) ;
fetch sp into myrecord;
while sp%found loop
dbms_output.put_line(myrecord.table_name);
fetch sp into myrecord;
end loop;
close sp ;
end;
--隐性游标
begin
for sp in (select * from user_tables) loop
dbms_output.put_line(sp.table_name);
end loop;
end;