首页 > 其他 > 详细

ORALCE 游标简单的实例

时间:2016-09-18 16:58:51      阅读:241      评论:0      收藏:0      [点我收藏+]

--取简单的游标

declare 
   cursor sp is 
   select * from user_tables;   
   myrecord user_tables%ROWTYPE;
begin
   open sp ;
   fetch sp into myrecord;
   while sp%found loop
     dbms_output.put_line(myrecord.table_name);   
     fetch sp into myrecord;
   end loop;
   close sp ;  
end;

--带参数的游标

declare 
   cursor sp(rownum number) is 
   select * from user_tables a where a.NUM_ROWS>=rownum;   
   myrecord user_tables%ROWTYPE;
begin
   open sp(10000) ;
   fetch sp into myrecord;
   while sp%found loop
     dbms_output.put_line(myrecord.table_name);   
     fetch sp into myrecord;
   end loop;
   close sp ;  
end;

--隐性游标

begin
   for sp in  (select * from user_tables) loop
     dbms_output.put_line(sp.table_name);   
   end loop;
end;

 

ORALCE 游标简单的实例

原文:http://www.cnblogs.com/champaign/p/5882195.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!