在一个存储过程可否引用函数的返回游标,并循环取值.
如果可以的话,能否给出例子. 谢谢! 
存储过程Oracle

解决方案 »

  1.   

    可以的,如decode()函数
    SQL> create or replace procedure test1(rcursor out sys_refcursor) as
      2  begin
      3    open rcursor for
      4      select decode(row_number() over(partition by deptno order by ename),
      5                    1,
      6                    deptno,
      7                    null) deptno,
      8             t.ename
      9        from scott.emp t;
    10  end;
    11  /Procedure created.SQL> var cur refcursor
    SQL> exec test1(:cur);
      

  2.   

    感谢回复! 我的问题估计是没说清楚,不好意思.
    我的问题是这样:
    在一个包体里,自定义Function 函数 Query(), 这个Query() 返回一个sys_refcursor 游标.
    同时在这个包体里,还有一个Procedure DoPro() 存储过程,我想在这存储过程里 使用 Query()函数的返回游标,并使用loop循环取值.
    请问这样可以么?