首页 > 数据库 > 数据库开发技术 > PL/SQL cursor
CURSOR
1 declare
cursor a(i number) is select * from test where id=i;
b test%rowtype;
begin
open a(i=>1) ;
loop
fetch a into b;
exit when a%notfound;
dbms_output.put_line(b.name);
end loop;
close a;
end;
2 declare
begin
for a in (select * from test) loop
dbms_output.put_line(a.name);
end loop;
end;
3 declare
cursor b(i number) is select * from test where id=i;
begin
for c in b(i=>1) loop
dbms_output.put_line(c.name);
end loop;
end;
4
declare
cursor a is select * from mao where rownum<100;
b mao%rowtype;
begin
for b in a loop
dbms_output.put_line(b.name);
end loop;
end;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9907339/viewspace-1037862/ ,如需转载,请注明出处,否则将追究法律责任。