我有一个函数返回一个记录列表,然后我循环遍历列表并管道它们,但是在管道中我得到ORA-01403: no data found
错误。
下面是我正在使用的代码,我在某些行上收到此错误,而不是所有行。
注意:tab_pipe.t_tab
和tab.t_tab
是同一记录tab.r_tab
的表格。
Function pipelinedFunction(ref varchar2, seq varchar2) Return tab_pipe.t_tab pipelined Is
pragma autonomous_transaction;
errtxt varchar2(400);
tab tab.t_tab;
begin
tab := generate_table(ref, seq);
for i in 1 .. tab.count loop
begin
pipe row(tab(i));
EXCEPTION
when others then
v_errtxt := sqlerrm;
insert into test_kc values('an error occurred piping the row i = ' || i || ' - sqlerrm = ' || v_errtxt); commit;
end;
end loop;
return;
end pipelinedFunction;
答案 0 :(得分:2)
对于i的每个值,也许选项卡中没有条目。
使用第一个和下一个
尝试循环declare
l_index PLS_INTEGER;
BEGIN
l_index := tab.FIRST;
WHILE (l_index IS NOT NULL)
LOOP
pipe row(tab(l_index));
l_index := tab.NEXT(l_index);
END LOOP;
END;