Xquery with Union
As I am not able to use IF-ELSE in Oracle for select statements, I am using UNION to discard one select query result set and to get resultset of other query depending upon the Parameter value.
Example of Normal Query:
Select FNAME , LNAME from EMP where Param.1 in ( 'NAME' , 'SURNAME' )
UNION
SELECT CITY , ADDRESS from EMP where Param.1 in ( 'LOCATION' , 'ADDRESS')
so when I give Param.1 as "NAME", it gives me the result set of first query while it discards resultset of other query as it will be null coz Param.1 i snot in 'Location' or 'ADDRESS".
Same wau if I give Param.1 as "ADDRESS", it gives me the resultset of 2nd query and discards 1st query resultset as it is null.
But same approach doesnot work for Oracle query with Xquery for following:
Select rtrim(XMLELEMENT( "Rowset" , XMLAGG ( RW.column_value) ) , ',' ) AS Orders
from EMPTABLE UL, XMLTABLE('Rowsets/Rowset/Row' PASSING UL.TEXT) AS RW
WHERE
[Param.1] IN ( 'NAME' , 'SURNAME' )
UNION
Select rtrim(XMLELEMENT( "Rowset" , XMLAGG ( RW.column_value) ) , ',' ) AS Orders
from ADDRESSTABLE UL, XMLTABLE('Rowsets/Rowset/Row' PASSING UL.TEXT) AS RW
WHERE
[Param.1] IN ( 'LOCATION' , 'ADDRESS' )
Here, if the Param.1 is "NAME" then the outcomes as <Rowset></Rowset> + Output of other query (which only thing I want)
How can i remove this <Rowset></Rowset> from the output?