Download presentation
Presentation is loading. Please wait.
1
XML In Action With Oracle
Insert, update, Delete using XML
2
Step 1 First, let's create a sample table
CREATE TABLE TEST_1 ( "EMP_ID" NUMBER NOT NULL ENABLE, "EMP_NAME" VARCHAR2(100 BYTE), "EMP_DETAIL" VARCHAR2(200 BYTE), "EMP_FLAG" NUMBER DEFAULT 0 )
3
Step 2 create a procedure
PROCEDURE InsertXML(xmlDoc IN CLOB , tableName IN VARCHAR2,inserted_rows out NUMBER) is xml_context DBMS_XMLStore.ctxType; BEGIN --Open a new context, required for these procedures xml_context := DBMS_XMLStore.newContext(tableName); --’inserted_rows' row count inserted inserted_rows := DBMS_XMLStore.insertXML( xml_context, xmlDoc); -- Close the context DBMS_XMLStore.closeContext(xml_context); end;
4
Step 3 create a Schema </xs:sequence>
</xs:complexType> </xs:element> <xs:element name="ROWSET"> <xs:complexType> <xs:sequence> <xs:element ref="ROW" maxOccurs="unbounded"/> <xs:element name="UP_DATE" type="xs:string"/> <xs:element name="EMP_DETAIL" type="xs:string"/> </xs:schema> <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs=" elementFormDefault="unqualified" attributeFormDefault="unqualified"> <xs:element name="EMP_FLAG" type="xs:string"/> <xs:element name="EMP_ID" type="xs:string"/> <xs:element name="EMP_NAME" type="xs:string"/> <xs:element name="ROW"> <xs:complexType> <xs:sequence> <xs:element ref="EMP_ID"/> <xs:element ref="EMP_NAME" minOccurs="0"/> <xs:element ref="EMP_DETAIL" minOccurs="0"/> <xs:element ref="EMP_FLAG" minOccurs="0"/> <xs:element ref="UP_DATE" minOccurs="0"/>
5
Step 4
7
Sample Data : <ROWSET> <ROW> <EMP_ID>1</EMP_ID> <EMP_NAME>Sujith</EMP_NAME> <EMP_FLAG>0</EMP_FLAG> </ROW> <EMP_ID>2</EMP_ID> <EMP_NAME>Vasudevan</EMP_NAME> <EMP_FLAG>1</EMP_FLAG> <EMP_ID>3</EMP_ID> </ROWSET>
8
Thank You
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.