Skip to content
Advertisement

Oracle XML Parse to Table Multiple Sub Elements

Hello I have an xml string I want to parse it to table. Problem is that when I have multiple sub categories in xml it throws exceptions.

[Error] Execution (27: 35): ORA-19279: XPTY0004 – XQuery dynamic type mismatch: expected singleton sequence – got multi-item sequence

MasaPersonelUrunleri, MasaPersonel can be more than one . When I write single every of them query below works but when I put one more element it throws error. How can solve the problem ?

Advertisement

Answer

You could use chained XMLTable calls, but in this case you can make your XPath go down to the multi-element level:

and then adjust the column paths to walk back up the tree:

which gets:

db<>fiddle


The chained XMLTable approach would be something like:

where each XMLTable is producing some of the columns; the multi-item sequence is the link between them, extracted from the first XMLTable and passed into the second.

db<>fiddle

PERSONEL varchar2(20) PATH './MASA/MasaPersonel/SICIL' causes problem when you have more than one MASA/MasaPersonel nodes

That isn’t shown in the sample in the question, but you can handle it with another chained XMLTable:

db<>fiddle

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement