ORA-01001 sql语句中使用的函数中的游标错误无效

时间:2015-11-26 11:50:41

标签: oracle oracle11g cursor sys-refcursor

当我尝试获取结果时,我在函数pipe_cursor中得到ORA-01001无效的游标错误,我无法弄清楚原因。

TYPE T_TBL:

CREATE OR REPLACE TYPE "T_TBL" as table of varchar2(36);

测试包:

create or replace package HOA_TEST is

 FUNCTION pipe_cursor(
                p_cur SYS_REFCURSOR
                ) RETURN t_tbl PIPELINED;

end HOA_TEST;
/
create or replace package body hoa_test is

  function pipe_cursor(p_cur in sys_refcursor) return t_tbl
    pipelined is
    v_ret rowid;
  begin

    if p_cur%isopen
    then

      loop
        fetch p_cur
          into v_ret;
        exit when p_cur%notfound;
        pipe row(v_ret);
      end loop;

      close p_cur;

    end if;

  end;

end hoa_test;
/

测试脚本:

declare 
  v_cur_newfilter SYS_REFCURSOR;
begin
  open v_cur_newfilter for select 1 from dual;
  open :cur for select column_value from table(HOA_TEST.pipe_cursor(v_cur_newfilter));
end;

注:

如果我将该功能称为

open :cur for select column_value from table(HOA_TEST.pipe_cursor(CURSOR(Select 1 from dual)));

它有效

我正在尝试这样做 Oracle Database 11g 11.2.0.3.0版 - 64位

0 个答案:

没有答案