oracle 游标使用(动态游标)

Set serveroutput on;   
declare
    type my_ref_cur is ref cursor;
    tmp_cur my_ref_cur;
    sqlStr varchar2(500);
    v_row xuesheng%rowtype;
begin
    sqlStr:='select xs.xing_ming,xs.yu_wen from xuesheng xs';
    open tmp_cur for sqlStr;
    
    loop
         fetch tmp_cur into v_row.xing_ming,v_row.yu_wen;
         exit when tmp_cur%NOTFOUND;
         
         dbms_output.put_line('xingming:'||v_row.xing_ming);
    end loop;
    close tmp_cur;
end;
/

 

posted @ 2014-07-11 17:59  mr.g.  阅读(1490)  评论(0编辑  收藏  举报