日期:2014-05-17  浏览次数:20765 次

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

------解决方案--------------------
可以的,如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);