Skip to Main Content

DevOps, CI/CD and Automation

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!

Generate xml element from Union of 2 Select queries

985031Jan 15 2013 — edited Jan 16 2013
Do you know ho I can get the union result of 2 queries and put them in xml result, but I want each query to be in seperate xml element.
I don t want to put 1 single xmlelement and do a From then construct a virtual table uniting the 2 subqueries

I mean I don t want something like the following:

(Select
XMLAGG(
XMLELEMENT("credit",
XMLForest(field1 "detail")
)
)
FROM
(
--SubQuery1
Select field1 from myTable1
union
--SubQuery1
Select field1 from myTable2
)
) "credits"

I want something like here:

XMLELEMENT("credits",
(SELECT
XMLAGG(
XMLELEMENT("credit",
XMLForest(field1 "field1")
)
)
FROM
myTable1
),
(SELECT
XMLAGG(
XMLELEMENT("credit",
XMLForest(field1 "field1")
)
)
FROM
myTable2
)
)

Except the 2nd alternative is not working Sad
I get error message:
"SQL command not properly ended"

Thanks a lot
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 13 2013
Added on Jan 15 2013
7 comments
2,079 views