将光标传递给函数始终不起作用

时间:2016-05-11 17:21:40

标签: oracle plsql parallel-processing cursor

我有以下程序和函数,我将游标结果作为参数传递给函数load_in_parallel。问题是,有时条目会被处理,而其他时间则不会。我真的不明白为什么会这样。可能是由于结果的大小?请参阅PL / SQL过程和功能,如下所示

    procedure COPY_REPORT_CONTENTS is
  begin
    begin

  -- START PARALLEL processing from here
  for rec in (
        select /*+ parallel(5) */ * from table(load_in_parallel(CURSOR(
            select gen_report_id, creation_ts, selection_criteria, content from stage_table stgrep where not exists(select 1 from content rep where rep.report_id = stgrep.gen_report_id) and nvl(stgrep.gen_report_id, 0) <> 0)))
           )
    LOOP
          --some processing here
    END LOOP;
    exception
      when others then
         ROLLBACK;
         raise;
    end;
  end;

  function load_in_parallel (c_pis_a1 IN SYS_REFCURSOR)
  return vdps_load_stats
  PARALLEL_ENABLE (PARTITION c_pis_a1 BY ANY)
  PIPELINED
  IS
    PRAGMA AUTONOMOUS_TRANSACTION;
  begin
    loop
      begin
        fetch c_pis_a1 into r_pis_a1;
        exit when c_pis_a1%notfound;
        --some processing
     commit;
     exception
    when others then
        rollback;
        --move the records to failed table and continue with next records
        commit;
    end;
    end loop;
    close c_pis_a1;
  PIPE ROW(v_vdps_load_stats);
  RETURN;
     end;

真的很感激任何帮助。

注意:包含缺少的异常块。

0 个答案:

没有答案