Oracle EBS技术爱好者论坛:[ www.techwind.net ] Oracle EBS MSN 交流群 :group199946@msnzone.cn 欢迎加入! 朋友的原单外贸鞋店(做技术的,大多都厚道): http://shoe1314.totaobao.com/

游标Cursor的一些写法。

上一篇 / 下一篇  2008-02-15 11:32:29 / 个人分类:Database

显式,隐式游标。

隐式:

declare
type c1 is ref cursor return xx_test_simon%rowtype;
c3 c1;
c2 xx_test_simon%rowtype;
begin
open c3 for
select * into c2 from xx_test_simon;
fetch c3 into c2;
while c3 %found
loop
dbms_output.put_line(c2.a1||'-'||c2.a2||'-'||c2.a3||'-'||c2.a4);
fetch c3 into c2;
end loop;
end;

显式:

declare
cursor c1 is select * from xx_test_simon;
c2 c1%rowtype;
begin
open c1;
loop
fetch c1 into c2;
exit when c1%notfound;
dbms_output.put_line(c2.a1||'-'||c2.a2||'-'||c2.a3||'-'||c2.a4);
end loop;
close c1;
end;

简单写法1:

begin
for c2 in (select * from xx_test_simon) loop
dbms_output.put_line(c2.a1||'-'||c2.a2||'-'||c2.a3||'-'||c2.a4);
end loop;
end;

简单写法2:

Declare
Cursor Cur_test is
select * from xx_test_simon;
begin
for c2 in Cur_test loop
dbms_output.put_line(c2.a1||'-'||c2.a2||'-'||c2.a3||'-'||c2.a4);
end loop;
end;


TAG: database ebs erp oracle cursor

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar