In SQL Server it is easy to parse a vachar variable that contains a simple XML snippet constructed with attributes and load it into a temp table - see example below:
declare @UpdateXML VARCHAR(8000)
set @UpdateXML='<ArrayOfRecords>
<Record Field01="130" Field02="1700" Field03="C" />
<Record Field01="131" Field02="1701" Field03="C" />
<Record Field01="132" Field02="1702" Field03="C" />
</ArrayOfRecords>'
DECLARE @hdoc int
EXEC sp_xml_preparedocument @hdoc OUTPUT, @UpdateXML
INSERT
INTO #tblTemp(
[Field01],
[Field02],
[Field03]
)
SELECT *
FROM OPENXML(@hdoc, '//ArrayOfRecords/Record')
WITH ( Field01 int,
Field02 int,
Field03 char(1)
)
EXEC sp_xml_removedocument @hdoc
Is there a simple example that does the equivalent of this in Oracle PL/SQL?
In Oracle there is an DBMS_XMLSTORE package but it wants the XML snippet in a specific canonical format using ROWSET and ROW elements. DBMS_XMLSTORE does not appear to work with XML attributes.
Also, I am not 100% sure if I need to create an XSD of my XML snippet and register that on the Oracle database before I can use any of the other PL/SQL XML tools/queries.
Thanks!