Search code examples
xmloracle-databaseoracle12c

oracle 12c --> Transform XML Record to Table


Greetings. I have XML Record as follows in oracle 12c

<row id='1'>
 <c1>rec1</c1>
 <c2>a</c2>
 <c2>b</c2>
 <c2>c</c2>
</row>

The same needs to be transformed as below

c1      c2
---     ---
rec1    a
rec1    b
rec1    c

Please help


Solution

  • Finally i found the answer. The below query will transform the data into table as expected

    SELECT RECID, MULTIVALUE 
    FROM <TABLE_NAME> , 
        XMLTABLE('/row/c2' PASSING <COLUMN_NAME> COLUMNS MULTIVALUE VARCHAR2(100) PATH '.');