首页 > 数据库技术 > 详细

oracle 游标使用(显式游标)

时间:2014-07-13 00:35:08      阅读:509      评论:0      收藏:0      [点我收藏+]

1.  

Set Serveroutput on;  

declare 
    Cursor tem_cursor is 
           select * from xuesheng xs;
           v_row tem_cursor%rowtype;
begin 
    open tem_cursor;
    loop
         fetch tem_cursor into v_row;
         exit when tem_cursor%NOTFOUND;
         dbms_output.put_line(v_row.xing_ming);
    end loop;
    close tem_cursor;
end;
/

2.

set serveroutput on;
declare
    cursor tmp_cur is
           select xing_ming,yu_wen,shu_xue from xuesheng;
           v_xing_ming xuesheng.xing_ming%type;
           v_yu_wen xuesheng.yu_wen%type;
           v_shu_xue xuesheng.shu_xue%type;
begin
    open tmp_cur;
    loop
         fetch tmp_cur into v_xing_ming,
                            v_yu_wen,
                            v_shu_xue;
         exit when tmp_cur%NOTFOUND;
         dbms_output.put_line(v_xing_ming);
    end loop;
    close tmp_cur;
end;
/

 3.

set serveroutput on;
declare
    cursor tem_cur is
           select xs.xing_ming,xs.yu_wen,xs.shu_xue 
           from xuesheng xs;
begin
    for tem_xs in tem_cur 
    loop
        dbms_output.put_line(tem_xs.xing_ming);
    end loop;
end;
/

 

数据库前面的章节中有。(不喜勿喷哦)

oracle 游标使用(显式游标),布布扣,bubuko.com

oracle 游标使用(显式游标)

原文:http://www.cnblogs.com/mrgong/p/3838233.html

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