This content has been marked as final.
Show 1 reply
-
1. Re: How to convert the sql query result into xml ? PLease..Please..
rareddy Jun 19, 2012 1:31 PM (in response to ocs2me)Jason,
Took me little time, but here is what I got, it was working as expected.
SELECT CASE WHEN LOCATE('<', x.name) = 0 THEN name ELSE (select doc.name from XMLTABLE('/*' PASSING XMLPARSE(DOCUMENT x.name) COLUMNS name string PATH 'text()') as doc) END as foo FROM (SELECT * FROM TEXTTABLE(UNESCAPE('name\nApple\nBanana\nOrange\n<Name> Jason </Name>\nTomato\n<Drink> Cola </Drink>') COLUMNS name string HEADER) as y) as x
Note the "FROM" clause, I am just trying to duplicate contents of your table, you would replace that with your table name. What I did is check the charcter at position 1, if it is "<" then I assumed that as XML, then parsed it and grabbed the first text out of it, else used the name as is.
Hope this helps.
Ramesh..