当我尝试获取结果时,我在函数 pipe_cursor 中收到 ORA-01001 Invalid Cursor 错误,但我无法弄清楚原因。
类型 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 Release 11.2.0.3.0 - 64bit 上执行此操作