ORA-06502:PL / SQL:数字或值错误:指定了无效的LOB定位符:ORA-22275

时间:2018-01-25 09:57:28

标签: oracle plsql

我不确定我是否正确行事,但我正在尝试将旧表格复制到新表格中,并且当我发现这个奇怪的错误时,我会发现这个奇怪的错误我的课程中甚至没有高手。

错误: writeRoot1中的错误:ORA-06502:PL / SQL:数字或值错误:指定了无效的LOB定位符:ORA-22275

我添加的代码:

   L_cms_exist VARCHAR2(1);

   cursor C_CMS_IMPORT is
      select 'Y'
        from vic_poe_entry pe,
             vic_poe_tb_po_head ptb
       where pe.order_no = ptb.order_no
         and NVL(cms_ind,'N') = 'Y'
         and pe.order_no = L_order_no
         and rownum = 1;

整个计划:

----WHENEVER SQLERROR EXIT sql.sqlcode;
SET ECHO ON;
SET FEEDBACK ON;
SET TERMOUT ON;
SET LINESIZE 32767;
SET TIMING ON;
SET TIME ON;
SET SERVEROUTPUT ON SIZE 1000000;
CLEAR BUFFER;

DECLARE
   L_order_no      ORDHEAD.ORDER_NO%TYPE;
   def_struct      VIC_APPROVE_PO_SQL.TAB_COLL;
   col_struct      VIC_APPROVE_PO_SQL.COL_COLL;
   L_error_message RTK_ERRORS.RTK_TEXT%TYPE := NULL;
   L_error_flag    VARCHAR2(1) := 'N';
   L_approve_ind   VIC_POE_ENTRY.APPROVE_IND%TYPE;
   L_tb_ind        VIC_POE_ENTRY.TB_IND%TYPE;
   L_update_ind    VARCHAR2(1) := 'N';
   L_cms_ind       VIC_POE_ENTRY.CMS_IND%TYPE;
   head_tab        VIC_PROCESS_PREPO_SUBMIT_SQL.head_tab;
   detail_tab      VIC_PROCESS_PREPO_SUBMIT_SQL.detail_tab;

   chk_ctr number:=0;
   L_num_po number:=0;
   L_flag   number:=0;
   L_program_status varchar2(100):=NULL;

   cursor C_num_of_po is
         select value
           from vic_parameter
          where module = 'VICAPPROVEPO'
            and parameter = 'NUM_OF_PO'; 

   cursor C_get_approved_po is
      select order_no,
             tb_ind,
             cms_ind
        from vic_poe_entry
       where status = 'A'
         and processed_date is NULL 
       order by submitted_date asc;

   cursor C_tab_cur is
     select *
       from vic_po_entry_defaults;

   cursor C_col_cur(I_table_name IN vic_po_entry_defaults.TABLE_NAME%TYPE) is
     select *
       from vic_po_entry_defaults
      where table_name = I_table_name;

   cursor C_lock_po is
      select 'x'
        from vic_poe_entry
       where order_no = L_order_no
         for update nowait;

   cursor C_approve_ind is
      select approve_ind
        from vic_poe_entry
       where status = 'A'
         and processed_date is NULL
         and order_no = L_order_no;

   cursor C_tbpo_head is
      select *
        from vic_poe_tb_po_head
       where order_no = L_order_no;

   cursor C_tbpo_detail is
      select x.order_no                    ,
             x.item                        ,
             pi.pack_no                    ,
             x.quote_no                    ,
             x.length                      ,
             x.width                       ,
             x.height                      ,
             x.mstr_pack_sets_unit_per_case,
             x.units_per_set               ,
             x.cubic_feet_manual           ,
             x.cubic_meters_manual         ,
             x.cubic_ft_from_sub_commodity ,
             x.unit_percent                ,
             x.unit_set_first_cost         ,
             x.freight_rate_manual         ,
             x.nested_packname             ,
             x.nested_packcode             ,
             x.selling_royalty             ,
             x.selling_commission          ,
             x.picture_address             ,
             x.load_pct                    ,
             x.mst_packs_unit_case         ,
             x.cubic_ft_calc               ,
             x.unit_calc_elc               ,
             x.ttl_elc                     ,
             x.ext_retail                  ,
             x.first_podtl_budget_month    ,
             x.second_podtl_budget_month   ,
             x.third_podtl_budget_month    ,
             x.fourth_podtl_budget_month   ,
             x.fifth_podtl_budget_month    ,
             x.sixth_podtl_budget_month    ,
             x.dd_ind               ,
             x.last_update_id,
             x.hts,
             x.customs_desc,
             x.item_parent,
             x.misc_cost,
             x.add_val,
             x.cvd_val,
             x.unit_pct_pack,
             x.ttl_first_cost,
             x.ordered_qty

      from
      (
       select tbpo_dtl.order_no                     ,
              rpi.item                              ,
              tbpo_dtl.pack_no                      ,
              tbpo_dtl.quote_no                     ,
              tbpo_dtl.length                       ,
              tbpo_dtl.width                        ,
              tbpo_dtl.height                       ,
              tbpo_dtl.mstr_pack_sets_unit_per_case ,
              tbpo_dtl.units_per_set                ,
              tbpo_dtl.cubic_feet_manual            ,
              tbpo_dtl.cubic_meters_manual          ,
              tbpo_dtl.cubic_ft_from_sub_commodity  ,
              tbpo_dtl.unit_percent                 ,
              tbpo_dtl.unit_set_first_cost          ,
              tbpo_dtl.freight_rate_manual          ,
              tbpo_dtl.nested_packname              ,
              tbpo_dtl.nested_packcode              ,
              tbpo_dtl.selling_royalty              ,
              tbpo_dtl.selling_commission           ,
              tbpo_dtl.picture_address              ,
              tbpo_dtl.load_pct                     ,
              tbpo_dtl.mst_packs_unit_case          ,
              tbpo_dtl.cubic_ft_calc                ,
              tbpo_dtl.unit_calc_elc                ,
              tbpo_dtl.ttl_elc                      ,
              tbpo_dtl.ext_retail                   ,
              tbpo_dtl.first_podtl_budget_month     ,
              tbpo_dtl.second_podtl_budget_month    ,
              tbpo_dtl.third_podtl_budget_month     ,
              tbpo_dtl.fourth_podtl_budget_month    ,
              tbpo_dtl.fifth_podtl_budget_month     ,
              tbpo_dtl.sixth_podtl_budget_month     ,
              tbpo_dtl.dd_ind                       ,
              tbpo_dtl.last_update_id,
              rpi.hts,
              rpi.customs_desc,
              rpi.item_parent,
              rpi.misc_cost,
              rpi.add_val,
              rpi.cvd_val,
              rpi.unit_pct_pack,
              rpi.ordered_qty * tbpo_dtl.unit_set_first_cost AS "TTL_FIRST_COST",
              rpi.ordered_qty
         from vic_poe_items rpi,
              vic_poe_tb_po_detail tbpo_dtl
        where rpi.order_no = L_order_no
          and rpi.order_no = tbpo_dtl.order_no
          and rpi.rec_no = tbpo_dtl.rec_no
          and rpi.pack_ind != 'Y'
        order by tbpo_dtl.order_no,
              tbpo_dtl.pack_no,
              UPPER(decode((SUBSTR(UPPER(tbpo_dtl.nested_packcode),1,1)), 'Z', SUBSTR(UPPER(tbpo_dtl.nested_packcode),2,2), tbpo_dtl.nested_packcode)),
              tbpo_dtl.item) x,
              packitem pi
        where x.item = pi.item(+);
   L_cms_exist VARCHAR2(1);

   cursor C_CMS_IMPORT is
      select 'Y'
        from vic_poe_entry pe,
             vic_poe_tb_po_head ptb
       where pe.order_no = ptb.order_no
         and NVL(cms_ind,'N') = 'Y'
         and pe.order_no = L_order_no
         and rownum = 1;
   RECORD_LOCKED     EXCEPTION;
   PRAGMA            EXCEPTION_INIT(RECORD_LOCKED, -54);

BEGIN
   OPEN C_num_of_po;
   FETCH C_num_of_po into L_num_po;
   CLOSE C_num_of_po;


   for tab_rec in C_tab_cur
   LOOP

      col_struct.DELETE;
      ---
      for col_rec in C_col_cur(tab_rec.table_name)
      LOOP
         col_struct(col_rec.column_name) := col_rec.value;
      END LOOP;
      ---
      def_struct(tab_rec.table_name) := col_struct;
   END LOOP;

   SQL_LIB.SET_MARK('OPEN',
                    'C_get_approved_po',
                    'vic_poe_entry',
                    'order_no :'|| TO_CHAR(L_order_no));
   open C_get_approved_po;
   ---
   WHILE L_flag = 0
   LOOP

      chk_ctr := chk_ctr + 1;

      SQL_LIB.SET_MARK('FETCH',
                       'C_get_approved_po',
                       'vic_poe_entry',
                       'order_no :'|| TO_CHAR(L_order_no));
      fetch C_get_approved_po into L_order_no, L_tb_ind, L_cms_ind;
      if C_get_approved_po%NOTFOUND then
         exit;
      end if;
      open C_approve_ind;
      fetch C_approve_ind into L_approve_ind;
         ---
         if L_approve_ind = 'N' then
            update vic_poe_entry
               set approve_ind = 'Y'
             where order_no = L_order_no;
            commit;
         end if;
      close C_approve_ind;
      <<force_error_loop>>
      for x in 1..5 LOOP
         BEGIN
            L_error_flag := 'N';      --reset flag
            L_error_message := NULL;  --reset error message
            open C_lock_po;
            close C_lock_po;

            --- Process Item details
            if VIC_POE_PROCESS_ITEM.PROCESS_ITEM(L_error_message,
                                                 L_order_no,
                                                 def_struct) = FALSE then
               ROLLBACK;
               L_error_flag := 'Y';
            end if;
            --- Process PO details
            if L_error_message is NULL
               and L_error_flag = 'N' then
               if VIC_POE_PROCESS_PO.PROCESS_PO(L_error_message,
                                                L_order_no,
                                                def_struct) = FALSE then
                  ROLLBACK;
                  L_error_flag := 'Y';
               else

                  open C_CMS_IMPORT;
                  fetch C_CMS_IMPORT into L_cms_exist;
                  close C_CMS_IMPORT;
                  if nvl(L_tb_ind, 'N') = 'Y' OR L_cms_exist is NOT NULL then
                     SQL_LIB.SET_MARK('OPEN',
                                      'C_TBPO_HEAD',
                                      'VIC_POE_TB_PO_HEAD',
                                      'ORDER_NO: '|| TO_CHAR(L_order_no));
                     --
                     open C_tbpo_head;
                     --
                     SQL_LIB.SET_MARK('FETCH',
                                      'C_TBPO_HEAD',
                                      'VIC_POE_TB_PO_HEAD',
                                      'ORDER_NO: '|| TO_CHAR(L_order_no));
                     --
                     fetch C_tbpo_head into head_tab.vic_tbpo_head;
                     --
                     SQL_LIB.SET_MARK('CLOSE',
                                      'C_TBPO_DETAIL',
                                      'VIC_POE_TB_PO_HEAD',
                                      'ORDER_NO: '|| TO_CHAR(L_order_no));
                     --
                     close C_tbpo_head;
                     --
                     -- Get TB PO Detail Data
                     SQL_LIB.SET_MARK('OPEN',
                                      'C_TBPO_DETAIL',
                                      'VIC_POE_TB_PO_DETAIL',
                                      'ORDER_NO: '|| TO_CHAR(L_order_no));
                     --
                     open C_tbpo_detail;
                     --
                     SQL_LIB.SET_MARK('FETCH',
                                      'C_TBPO_DETAIL',
                                      'VIC_POE_TB_PO_DETAIL',
                                      'ORDER_NO: '|| TO_CHAR(L_order_no));
                     --
                     fetch C_tbpo_detail bulk collect into detail_tab;
                     --
                     SQL_LIB.SET_MARK('CLOSE',
                                      'C_TBPO_DETAIL',
                                      'VIC_POE_TB_PO_DETAIL',
                                      'ORDER_NO: '|| TO_CHAR(L_order_no));
                     --
                     close C_tbpo_detail;
                     --
                     if VIC_PROCESS_PREPO_SUBMIT_SQL.INSERT_UPD_TB_INFO (L_error_message,
                                                                         head_tab,
                                                                         detail_tab,
                                                                         L_update_ind) = FALSE then
                        ROLLBACK;
                        L_error_flag := 'Y';
                     else
                        if VIC_POE_PROCESS_PO.POST_PO_VALIDATION(L_error_message,
                                                                 L_order_no) = FALSE then
                           ROLLBACK;
                           L_error_flag := 'Y';
                        else
                           L_error_flag := 'N';
                           exit force_error_loop;
                        end if;

                     end if;
                  else
                     if VIC_POE_PROCESS_PO.POST_PO_VALIDATION(L_error_message,
                                                              L_order_no) = FALSE then
                        ROLLBACK;
                        L_error_flag := 'Y';
                     else
                        L_error_flag := 'N';
                        exit force_error_loop;
                     end if;

                  end if;
               end if;
            end if;
         EXCEPTION
            when RECORD_LOCKED then
               ROLLBACK;
               L_error_flag := 'L';
         END;

      END LOOP force_error_loop;

      SQL_LIB.SET_MARK('UPDATE',
                       'C_get_approved_po',
                       'vic_poe_entry',
                       'order_no :'|| TO_CHAR(L_order_no));

      if L_error_flag = 'N' then
         update vic_poe_entry
            set processed_date = sysdate,
                  is_processed = 'Y'

          where order_no = L_order_no;

      elsif L_error_flag = 'Y' then
         ROLLBACK; --Roll back any changes first.
         ---
         update vic_poe_entry
            set status = 'W',
                float_ind = 'Y'
          where order_no = L_order_no;
          ---

          DBMS_OUTPUT.PUT_LINE('Error processing order_no: '||L_order_no||' : '||SUBSTR(L_error_message,1,220));
          if LENGTH(L_error_message) > 220 then
             DBMS_OUTPUT.PUT_LINE(SUBSTR(L_error_message,221));
          end if;
      elsif L_error_flag = 'L' then
         DBMS_OUTPUT.PUT_LINE('Cannot process locked PO : '||L_order_no||'.');

      end if;
      ---
      COMMIT;


      VICAPPS.VIC_SAMPLE.P_UPDATE_SAMPLE_PO_APPROVAL(L_order_no);

      ---
      L_error_flag := 'N';
      L_error_message := NULL;


      if chk_ctr = L_num_po then
         select value
           into L_program_status
           from vic_parameter
          where module = 'VICAPPROVEPO'
            and parameter = 'PROGRAM_STATUS';

         if L_program_status = 'COMPLETED' then
            dbms_output.put_line('PASOK');
            L_flag:= 1;
         end if;

         chk_ctr:= 0;
         L_program_status := NULL; 

      end if;


   END LOOP;
   ---
   SQL_LIB.SET_MARK('CLOSE',
                    'C_get_approved_po',
                    'vic_poe_entry',
                    'order_no :'|| TO_CHAR(L_order_no));
   close C_get_approved_po;
EXCEPTION
   when OTHERS then
      L_error_message := SQL_LIB.CREATE_MSG (' SCRIPT_ERROR ',
                                             SQLERRM,
                                             ' VIC_APPROVE_PO_SQL.SQL ',
                                             TO_CHAR(SQLCODE));
         DBMS_OUTPUT.PUT_LINE(L_error_message);
         ROLLBACK;
END;
/

0 个答案:

没有答案