1

レコードのリストを返す関数があり、リストをループしてパイプしますが、パイプ中にORA-01403: no data foundエラーが発生します。

以下は私が使用しているコードです。すべての行ではなく、一部の行でこのエラーが発生しています。

注:tab_pipe.t_tabtab.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;
4

1 に答える 1

2

i の値ごとにタブにエントリがない可能性があります。

first と next を使用してループを試す

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;
于 2016-10-26T12:28:30.167 に答える