Oracle(11g)奇怪的xquery行为

时间:2015-12-16 09:50:14

标签: xml oracle oracle11g xquery

我有一个非常奇怪的xquery问题。我在一个大的xml上循环,大约有80000个节点值:

     insert
    into xxif_vendor_onhand_interface (
         vendor_onhand_interface_id
        ,created_by
        ,creation_date
        ,last_updated_by
        ,last_update_date
        ,status_code
        ,vendor_site_id
        ,org_id
        ,inventory_item_id
        ,vendor_item_number
        ,vendor_onhand_quantity)
  select xxif_vendor_onhand_interface_s.nextval
        ,fnd_global.user_id
        ,sysdate
        ,fnd_global.user_id
        ,sysdate
        ,'NEW'
        ,vs.vendor_site_id
        ,vs.org_id
        ,asl.item_id
        ,asl.primary_vendor_item
        ,x.oh_qty
    from xxpo_vendor_site_attributes   vsa
        ,po_vendor_sites_all           vs
        ,xmltable(
         'for $i in /TBSTOCK/ARTICLE return $i'
         passing l_xml
         columns "TB_SKU" varchar2(50) path '/ARTICLE/A_NR'
                ,"OH_QTY" number path '/ARTICLE/A_STOCK'
         ) x
        ,po_approved_supplier_list     asl
   where vsa.attribute_name            = '???'
     and vsa.attribute_value           = 'Y'                
     and vs.vendor_site_id             = vsa.vendor_site_id;

我希望结果中的数量相同,但结果中只有最后的10.000个值。

我确保使用此代码:

  --onhand logging
  BEGIN
     v_history_s := xxif_tb_onhand_history_s.NEXTVAL;

     INSERT INTO xxif_tb_oh_history_headers (xxif_tb_onhand_history_id,
                                             onhand_xml,
                                             created_by,
                                             creation_date,
                                             last_updated_by,
                                             last_update_date,
                                             last_update_login)
          VALUES (v_history_s,
                  l_xml,
                  NVL (fnd_global.user_id, -1),
                  SYSDATE,
                  NVL (fnd_global.user_id, -1),
                  SYSDATE,
                  NVL (fnd_global.login_id, -1));


     FOR r
        IN (SELECT EXTRACTVALUE (VALUE (p), '/ARTICLE/A_NR') AS a_nr,
                   EXTRACTVALUE (VALUE (p), '/ARTICLE/A_STOCK') AS a_stock
              FROM TABLE (XMLSEQUENCE (EXTRACT (l_xml, '/TBSTOCK/ARTICLE'))) p)
     LOOP
        INSERT INTO xxif_tb_oh_history_lines (xxif_tb_onhand_history_id,
                                              a_nr,
                                              a_stock,
                                              created_by,
                                              creation_date,
                                              last_updated_by,
                                              last_update_date,
                                              last_update_login)
             VALUES (v_history_s,
                     r.a_nr,
                     r.a_stock,
                     NVL (fnd_global.user_id, -1),
                     SYSDATE,
                     NVL (fnd_global.user_id, -1),
                     SYSDATE,
                     NVL (fnd_global.login_id, -1));
     END LOOP;
  EXCEPTION
     WHEN OTHERS
     THEN
        NULL;
  END;

似乎数据将在10.000条记录后被覆盖。我不知道问题出在哪里。表中只有xml的最后9.000个值。

有什么想法吗?

提前致谢 添

1 个答案:

答案 0 :(得分:0)

嗨伙计们, 我自己解决了。

  1. 我在clob中获取xmltype变量
  2. l_oh_clob:= l_xml.getClobVal();

    1. 将clob转换为xmltype
    2. XMLTABLE(  ' for $ i in / TBSTOCK / ARTICLE返回$ i'  传递xmltype(l_oh_clob)  列" TB_SKU" varchar2(50)路径' / ARTICLE / A_NR'         " OH_QTY"号码路径' / ARTICLE / A_STOCK'  ) X ,po_approved_supplier_list asl;

      不漂亮,但它有效!