ORA-22160 並非是稀梳數組引起來的

來源:互聯網
上載者:User

ORA-22160:  element at index [1] does not exist

昨天調了過程 搞了好久才找到原因.

procedure stat_month_to_tmp

 cursor  cur_state_month_tmp is
        select
        id as order_id,
        provinceid,
        areaid
        typeid,
        info_id,
        o.code,
        ordername,

from ....

 

begin

open cur_state_month_tmp;
    loop
      fetch cur_state_month_tmp bulk collect into
            l_ary_ID,
            l_ary_PROVINCEID,

            l_ary_TYPEID,
            l_ary_INFO_ID,
            l_ary_CODE,
            l_ary_ORDERNAME;

  l_rowcnt:=l_ary_ID.count;
      l_rowcnt:=l_ary_ID(1);
      forall x in 1..l_ary_ID.count
      merge into  delv_order_stat_mid using dual
       on (id =l_ary_id(x))
       when matched then
             update set
             complettime                   =l_ary_complettime(x),
             mail_succ_send           =mail_succ_send+l_ary_mail_succ_send (x),
             sms_succ_send          =sms_succ_send+l_ary_sms_succ_send (x),
             error                                 =l_ary_error (x),
             TASKSTATUS                 =L_ARY_TASKSTATUS(x),

when not matched then

 insert into oss_delv_order_stat_mid
          (
            id,
            provinceid,
            areaid,
            typeid,
            info_id,
            code,
            ordername,
            insert_time,
            modfiy_time
                   
          )
          values(
            l_ary_id  (i),
            l_ary_provinceid  (i),

           l_ary_areaid  (i),
            l_ary_typeid  (i),
            l_ary_info_id  (i),
            l_ary_code  (i),
            l_ary_ordername  (i),
            sysdate,
            sysdate
          );

 

run at merge into  delv_order_stat_mid using dual  report eror!!!

ORA-22160:  element at index [1] does not exist

  l_rowcnt:=l_ary_ID.count;
  l_rowcnt:=l_ary_ID(1);

都有資料啊 !

後來 好久 好久才發現 多了個 l_ary_areaid(i) 這個在搜集當中沒有    fetch cur_state_month_tmp bulk collect into

          values(
            l_ary_id  (i),
            l_ary_provinceid  (i),

           l_ary_areaid  (i),

 

 

我在收集加上去報 l_ary_ORDERNAME; 類型錯誤!  反覆對照 遊標和表的類型,還有核對列數....

後來後來 把遊標裡的SQL 拿到查詢時段運行 然後複製列名 用ULTRAEDIT 開兩個文本 發現 查詢出來的少了1列

  areaid
沒有逗號 查詢語句把它給忽略掉. 文法不檢查,太怪了!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.