oracle游标使用遍历3种方法
Posted 游浪踏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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种方法的主要内容,如果未能解决你的问题,请参考以下文章
Oracle动态游标实现动态SQL循环遍历,和静态游标的比较。