Oracle PLSQL Demo - 20.弱类型REF游标[没有指定查询类型,也不指定返回类型]

declare

    Type ref_cur_variable IS REF cursor;
    cur_variable ref_cur_variable;
    
    v_ename varchar2(10);
    v_deptno number(2);
    v_sal number(7,2);

    v_sql varchar2(100) := 'select t.ename, t.deptno, t.sal from scott.emp t';

begin

    Open cur_variable For v_sql;
    
    Loop
        fetch cur_variable
            InTo v_ename, v_deptno, v_sal;
        Exit When cur_variable%NotFound;
        dbms_output.put_line(cur_variable%rowcount || ' -> ' || v_ename ||
                             '   ' || v_deptno || '   ' || v_sal);
    End Loop;
    Close cur_variable;

end;

 

posted @ 2015-06-29 23:06  nick_huang  阅读(219)  评论(0编辑  收藏  举报