Since i recently got a comment here on OTN that extract/extractvalue shouldn't be used anymore to extract XML I've been playing around with xmltable.
I'm however running into a small problem.
I try to extract a very simple piece of xml in this way:
SELECT d.*
FROM (SELECT xmltype ('<ArrayOfstring>
<string>415391</string>
<string>415392</string>
</ArrayOfstring>
')
x
FROM DUAL),
XMLTABLE ('$d/ArrayOfstring'
PASSING x AS "d"
COLUMNS string VARCHAR2 (100) PATH 'string') d;
and I get this error: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequence - got multi-item sequence
I don't quite get what's going wrong, since the same code does work with a more complex pieve of xml:
SELECT d.*
FROM (SELECT xmltype ('<ArrayOfProperties>
<Properties>
<Id>98247</Id>
<code>001</code>
<name>4 Megapixel</name>
</Properties>
<Properties>
<Id>98248</Id>
<code>001</code>
<name>5 Megapixel</name>
</Properties>
</ArrayOfProperties>') x FROM DUAL),
XMLTABLE (
'$d/ArrayOfProperties/Properties'
PASSING x AS "d"
COLUMNS Id VARCHAR2 (100) PATH 'Id',
Naam VARCHAR2 (4000) PATH 'name',
code VARCHAR2 (100) PATH 'code') d
Edited by: Erik_NL on 20-jul-2012 6:11