Hi,
Below is the query need to rewrite inorder to generate XML output.
SQL query
SELECT lq.libquestion_id ,
lq.innertext ,
lq.content_id ,
lq.tags ,
lo.innertext AS lo_innertext,
lo.shared_id
FROM libraryquestions_ec lq
INNER JOIN libraryoptions_ec lo
ON lq.libquestion_id = lo.libquestion_idfk
WHERE lq.resolveRef IS NULL
ORDER BY lq.libquestion_id,
lo.shared_id
xml query
SQL> select xmlelement("lq",xmlforest(lq.libquestion_id ,
2 lq.innertext ,
3 lq.content_id ,
4 lq.tags ),xmlagg(xmlelement("lo",xmlforest(lo.innertext AS lo_innertext,
5 lo.shared_id)) )) from libraryquestions_ec lq
6 INNER JOIN libraryoptions_ec lo
7 ON lq.libquestion_id = lo.libquestion_idfk
8 WHERE lq.resolveRef IS NULL ORDER BY lq.libquestion_id,
9 lo.shared_id;
select xmlelement("lq",xmlforest(lq.libquestion_id ,
*
ERROR at line 1:
ORA-00937: not a single-group group function
SQL> spool off
Required Ouput
<lq>
<libquestion_id>5</libquestion_id>
<innertext>Check Oneview, has customer previously left their V-Box tuned to Setanta (CH34) (with viewing card inserted) for one hour in order for service to work?</innertext>
<content_id>0</content_id>
<lo>
<lo_innertext>Yes</lo_innertext>
<shared_id>1</shared_id>
</lo>
<lo>
<lo_innertext>No</lo_innertext>
<shared_id>2</shared_id>
</lo>
</lq>
<lq>
<libquestion_id>7</libquestion_id>
<innertext>Can the customer view webpages via the Ethernet/USB connection (for example, www.bt.com)?</innertext>
<content_id>0</content_id>
<lo>
<lo_innertext>Yes</lo_innertext>
<shared_id>1</shared_id>
</lo>
<lo>
<lo_innertext>No</lo_innertext>
<shared_id>2</shared_id>
</lo>
<lo>
<lo_innertext>Ethernet/USB Unavailable</lo_innertext>
<shared_id>4</shared_id>
</lo>
</lq>
Thanks in advance