I want to write a stored procedure which has a XML input (clob type) and inserts the data to a table. my XML structure is something like this:
<rowset>
<row>
<name>tom</name>
<family>mack</family>
....
</row>
<row>
<name>marry</name>
<family>skot</family>
....
</row>
...
</rowset>
I have just stock in many options that oracle gave me to handle this. using extractvalue and XMLSequence
– using DBMS_XMLDOM
– using DBMS_XMLStore
or many other options.
I want to know which one is better according to the performance and resources that use. the input XML is usually less than 50KB.
Best Answer
You can query your XML data directly in SQL with
XMLTABLE
:You can also use
XMLSequence
andEXTRACT
(see this SO question for example) but as noted in the documentation these functions are deprectated.Another option is
DBMS_XMLSTORE
, although you can't really customize it much (needs perfect match between input xml tags and output column names):I'm not sure performance-wise which option is faster, this certainly depends on the data -- you'll have to benchmark.