Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Group XML Data

Orcl ApexSep 26 2024

Hi All,

I have the data as below (sales order information including customer, their order, order line and item ordered). I want to turn this data into XML format into groups i.e. One group per account and then within the account another group is for the order number.

select 'A1' account, 1 orderno, 1 lineno, 'I1' item from dual union all

select 'A1' account, 1 orderno, 2 lineno, 'I2' item from dual union all

select 'A2' account, 2 orderno, 1 lineno, 'I1' item from dual union all

select 'A2' account, 2 orderno, 2 lineno, 'I2' item from dual union all

select 'A3' account, 3 orderno, 1 lineno, 'I1' item from dual union all

select 'A3' account, 3 orderno, 2 lineno, 'I2' item from dual

<account account=A1>

<orderno orderno=1>

<lineno> 1</lineno>

<item> I1 </item>

<lineno> 2</lineno>

<item> I2 </item>

</orderno>

</account>

<account account=A2>

<orderno orderno=2>

<lineno> 1</lineno>

<item> I1 </item>

<lineno> 2</lineno>

<item> I2 </item>

</orderno>

</account>

This post has been answered by mathguy on Sep 26 2024
Jump to Answer
Comments
Post Details
Added on Sep 26 2024
8 comments
82 views