码迷,mamicode.com
首页 > 其他好文 > 详细

ORALCE 游标简单的实例

时间:2016-09-18 16:59:59      阅读:187      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!