当前位置:Gxlcms > 数据库问题 > oracle游标使用遍历3种方法

oracle游标使用遍历3种方法

时间:2021-07-01 10:21:17 帮助过:37人阅读

1.for循环遍历

declare
cursor mycur is select * from ct_cust_info;
custInfo ct_cust_info%rowtype;
cou number;
begin
for custInfo in mycur loop
cou:=mycur%rowcount;
dbms_output.put_line(cou);
dbms_output.put_line(custInfo.cust_id);
end loop;
end;

2.while遍历

declare
cursor mycur is select * from ct_cust_info;
custInfo ct_cust_info%rowtype;
begin
open mycur;
fetch mycur into custInfo;
while(mycur%found)loop
dbms_output.put_line(custInfo.cust_id);
fetch mycur into custInfo;
end loop;
end;

3.loop遍历

declare
cursor mycur is select * from ct_cust_info;
custInfo ct_cust_info%rowtype;
begin
open mycur;
loop
fetch mycur into custinfo;
exit when mycur%notfound;
dbms_output.put_line(custInfo.cust_id);
end loop;
end;

oracle游标使用遍历3种方法

标签:inf   _id   使用   select   not   open   rac   for循环   begin   

人气教程排行