当前位置: 代码迷 >> Oracle开发 >> 请问:在一个存储过程可否引用函数的返回游标,并循环取值
  详细解决方案

请问:在一个存储过程可否引用函数的返回游标,并循环取值

热度:9273   发布时间:2013-02-26 00:00:00.0
请教:在一个存储过程可否引用函数的返回游标,并循环取值
在一个存储过程可否引用函数的返回游标,并循环取值.
如果可以的话,能否给出例子. 谢谢! 
存储过程 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);
  相关解决方案