Im new to oracle, what im trying is, I have an xml, i try to insert the same in a oracle database table, i have formed a query, when i try to insert it. i get some Error like
Error report - ORA-06550: line 35, column 84: PL/SQL: ORA-00933: SQL command not properly ended ORA-06550: line 5, column 2: PL/SQL: SQL Statement ignored 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:
i couldnt able to figure out what i missed, Suggest me how to change the query,
heres my XML and Query which im trying to work.
- <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>
my Query is
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;
I hope you understand my question, Thanx in advance.
You'll want to use the xmlsequence function. It will allow you to select a list of nodes from your XML object. If you'd like to use pl/sql, the replace xmltype, with your variable.