Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> How to Generate XML and call a query on it?

How to Generate XML and call a query on it?

From: ali <ali.jan_at_gmail.com>
Date: 15 Jul 2005 02:24:22 -0700
Message-ID: <1121419462.923328.4100@o13g2000cwo.googlegroups.com>


I have a table called RegionDetail with the following columns in it:

RegionNum char
RegionName char
People xml

The People column is an xml column. The first thing I need to do a query on this table that will return the result as xml. For example to do the same thing in SQL Serer 2005, I will do a query such as this:

SELECT * FROM RegionDetail as Region FOR XML AUTO, ELEMENTS, TYPE, ROOT('Regions')

This query will return me the xml in the desired format:

<Regions>

  <Region>

<RegionNum> ... </RegionNum>
<RegionName> ... </RegionName>
<People> ... </People>

  </Region>

  <Region>

<RegionNum> ... </RegionNum>
<RegionName> ... </RegionName>
<People> ... </People>

  </Region>

...

</Regions>

The next thing would be to run an XQuery on this. Again in SQL Server 2005, I will wrap the earlier SELECT in another SELECT, like this:

SELECT ( SELECT * FROM RegionDetail as Region FOR XML AUTO, ELEMENTS, TYPE, ROOT('Regions') ).query('\\Region')

My question is, how do i do the exact same using PL/SQL in Oracle (10g and above)?

ps. If there is a more appropriate place for this post, do tell. Received on Fri Jul 15 2005 - 04:24:22 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US