We are using Oracle 11g database with XMLDB installation. We are having table with XMLType columns. The structure of the XML will be same for all the rows in a table. The table will have other fiedls also.
Now I want to retrieve only the values of the particular node’s attribute values from all the rows as a string with some other relational fields. The table columns retrieved can be like TemplateId, TemplateVid,TemplatepartId.
The structure of the XML can be as follows:
<Template ID=1000 VID=1>
<TemplateParts>
<Template ID="4000" VID="1"/>
<Template ID="4001" VID="1"/>
</TemplateParts>
</Template>
So the table will have data for Template with TemplateId,Vid and TemplateXML. The TemplateXML field is an XMLType field. Now I want to retrieve all the TemplateId,Vid and its refereced template partIds as an XML table. The output should be as follows:
TemplateId - TemplateVid - TemplatePartId - TemplatepartVid
1000 1 4000 1
1000 1 4001 1
So anybody comes up with a correct Xquery for the above requirement.
As I have mentioned in my earlier comment, I have managed to get the IDs and VIDs which is stored under the Node /Template/TemplateParts/Template from xmltype column of all the rows. The query is as follows:
If sombody know better format,please post your sample query. I need as a normal query as the above format is not supported by my ORM tool. If you look at the above query you can notice that the XMLTable expression is to be placed after the From clause. This gives trouble when I try to form this query through my LLBLGen ORM tool.