簡體   English   中英

XML批量插入Oracle表

[英]Xml bulk insert in oracle table

我是oracle的新手,我正在嘗試的是什么,我有一個xml,我嘗試將其插入oracle數據庫表中,當我嘗試將其插入時,就形成了查詢。 我得到一些錯誤

錯誤報告-ORA-06550:第35行,第84列:PL / SQL:ORA-00933:SQL命令未正確結束ORA-06550:第5行,第2列:PL / SQL:SQL語句被忽略06550。00000-“第%行s,列%s:\\ n%s“ *原因:通常是PL / SQL編譯錯誤。 *行動:

我無法弄清楚我錯過了什么,建議我如何更改查詢,

這是我試圖工作的XML和Query。

 - <call> - <callSummary> <indId>100</indId> <notificationNo>notification</notificationNo> <orderNo>orderno</orderNo> </callSummary> - <callList> - <callDetails> <maintenancetype>1</maintenancetype> <serialNo>1</serialNo> <unitType>unit type</unitType> </callDetails> - <callDetails> <maintenancetype>1</maintenancetype> <serialNo>2</serialNo> <unitType>unit type</unitType> </callDetails> - <callDetails> <maintenancetype>2</maintenancetype> <serialNo>1</serialNo> <unitType>unit type</unitType> </callDetails> - <callDetails> <maintenancetype>2</maintenancetype> <serialNo>2</serialNo> <unitType>unit type</unitType> </callDetails> </callList> </call> 

我的查詢是

 DECLARE call_xml XMLTYPE := xmltype('<call><callSummary><indId>100</indId><notificationNo>notification</notificationNo><orderNo>orderno</orderNo><</callSummary><callList><callDetails><maintenancetype>1</maintenancetype><serialNo>1</serialNo><unitType>unit type</unitType></callDetails><callDetails><maintenancetype>1</maintenancetype><serialNo>2</serialNo><unitType>unit type</unitType></callDetails><callDetails><maintenancetype>2</maintenancetype><serialNo>1</serialNo><unitType>unit type</unitType></callDetails><callDetails><maintenancetype>2</maintenancetype><serialNo>2</serialNo><unitType>unit type</unitType></callDetails></callList></call>'); BEGIN INSERT INTO ORDER_DETAILS ( IND_ID,NOTIFICATION_NO,ORDER_NO,MAINT_TYPE,SERIAL_NO,UNIT_TYPE) SELECT call_xml.value('call/callSummary/indId[1]','CLNT(3)'), call_xml.value('call/callSummary/notificationNo[1]','CHAR(12)'), call_xml.value('call/callSummary/orderNo[1]','CHAR(12)'), call_xml.value('call/callSummary/callList/callDetails/maintenancetype[1]','CHAR(1)'), call_xml.value('call/callSummary/callList/callDetails/serialNo[1]','CHAR(1)'), call_xml.value('call/callSummary/callList/callDetails/unitType[1]','CHAR(20)') from call_xml.nodes('call'); END; 

希望您提前理解我的問題,Thanx。

您將要使用xmlsequence函數。 它將允許您從XML對象中選擇節點列表。 如果您想使用pl / sql,請使用變量替換xmltype。

      SELECT 
  extractValue(column_value,'callSummary/indId[1]'),
  extractValue(column_value,'callSummary/notificationNo[1]'),
  extractValue(column_value,'callSummary/orderNo[1]'),
  extractValue(column_value,'callSummary/callList/callDetails/maintenancetype[1]'),
  extractValue(column_value,'callSummary/callList/callDetails/serialNo[1]'),
  extractValue(column_value,'callSummary/callList/callDetails/unitType[1]') from table (
       xmlsequence(
         extract(
           xmltype('<call><callSummary><indId>100</indId><notificationNo>notification</notificationNo><orderNo>orderno</orderNo></callSummary><callList><callDetails><maintenancetype>1</maintenancetype><serialNo>1</serialNo><unitType>unit type</unitType></callDetails><callDetails><maintenancetype>1</maintenancetype><serialNo>2</serialNo><unitType>unit type</unitType></callDetails><callDetails><maintenancetype>2</maintenancetype><serialNo>1</serialNo><unitType>unit type</unitType></callDetails><callDetails><maintenancetype>2</maintenancetype><serialNo>2</serialNo><unitType>unit type</unitType></callDetails></callList></call>'),'/call/callSummary')));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM