2015-06-20 106 views
1

即时通讯新的oracle, 即时尝试是什么, 我有一个XML,我尝试插入相同的数据库表,我已经形成了一个查询,当我尝试插入它。我得到了一些错误,如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和查询其即时通讯努力工作。

- <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 (
 
\t \t 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;

我希望你明白我的问题,感谢名单提前。

+1

插入语句应该包含'INTO'。尝试调整,看看是否解决错误。 – Parfait

+0

@Parfait是的,我包括并试图..再次显示相同的错误 – ConquistadorAravinth

回答

2

你会想要使用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'))); 
+0

嘿尼克...它的工作人...感谢很多..你救了我的一天... :-) – ConquistadorAravinth

+0

没问题。乐意效劳。 – Nick