add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE tablename (xmldata) AS
SELECT '<Main>
<text>data</text>
<conformation>YES</conformation>
<details><id>1</id></details>
<details><id>2</id></details>
<details><id>3</id></details>
<details><id>4</id></details>
<child>
<tax>123</tax>
<phone>123</phone>
<details><id>1</id></details>
<details><id>2</id></details>
<details><id>3</id></details>
</child>
<child>
<details><id>1</id></details>
<details><id>2</id></details>
</child>
<child>
<details><id>1</id></details>
<details><id>2</id></details>
<details><id>3</id></details>
<details><id>4</id></details>
</child>
</Main>' FROM DUAL;
1 rows affected
SELECT d.ids,
c.ids
FROM tablename t
CROSS JOIN LATERAL (
SELECT LISTAGG(id, ',') WITHIN GROUP (ORDER BY id) AS ids
FROM XMLTABLE(
'/Main/details'
PASSING XMLTYPE(t.xmldata)
COLUMNS
id NUMBER(5,0) PATH './id'
)
) d
CROSS JOIN LATERAL (
SELECT LISTAGG(id, ',') WITHIN GROUP (ORDER BY id) AS ids
FROM XMLTABLE(
'/Main/child'
PASSING XMLTYPE(t.xmldata)
COLUMNS
child_no FOR ORDINALITY,
xml XMLTYPE PATH '.'
) x
CROSS JOIN XMLTABLE(
'/child/details'
PASSING x.xml
COLUMNS
id NUMBER(5,0) PATH './id'
)
GROUP BY x.child_no
) c
IDS IDS
1,2,3,4 1,2,3
1,2,3,4 1,2
1,2,3,4 1,2,3,4