首页 > 代码库 > oracle游标使用遍历3种方法
oracle游标使用遍历3种方法
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种方法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。