Skip to Main Content

Database Software

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!

XML parent child records

699077Feb 8 2010 — edited Feb 10 2010
Hello

I am trying to mimic the FOR XML EXPLICIT behavior of SQL Server code in Oracle 11g.


The XML EXPILICT mode transforms the rowset that results from the query execution into an XML document and it preserves the parent child relationship in the XML output. For example



SELECT customer.id,customer.name,order.id,order.date,orderdetail.id,orderdetail.pid
FROM CUSTOMER,ORDER,ORDERDETAIL
WHERE CUSTOMER.ORDERID=ORDER.ORDERID
AND
ORDER.ORDERID=ORDERDETAIL.ORDERID


<Customer ID="C1" name="Ann">
<Order id="O1" date="1/20/2008">
<OrderDetail id="OD1" pid="P1"/>
<OrderDetail id="OD2" pid="P2"/>
</Order>
<Order id="O2" date="3/29/1997">
</Customer>

<Customer ID="C2" name="Jack">
<Order id="O1" date="1/20/2009">
<OrderDetail id="OF1" pid="P1"/>
<OrderDetail id="OF2" pid="P2"/>
</Order>
<Order id="O2" date="3/29/1997">
<OrderDetail id="OX1" pid="D1"/>
<OrderDetail id="OX2" pid="D2"/>
</Order>
</Customer>


Appreciate if you can help me to write an Oracle equivalent of this code.


Thanks & Regards
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 10 2010
Added on Feb 8 2010
2 comments
2,356 views