PL/SQL cursor

maojinyu發表於2010-09-04

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;

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9907339/viewspace-1037862/,如需轉載,請註明出處,否則將追究法律責任。

相關文章