Skip to Main Content

SQL & PL/SQL

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!

xmlagg giving some unexpected result

RanagalMay 14 2019 — edited May 15 2019

Hello experts,

I have this following query that was taken from the link Listagg function excdding 4000 characters which @"Solomon Yakobson" wrote in 2013. I modified it a bit to highlight my problem with the query. Can someone tell me about it ? I mean is there any other way to do the same without the need for additional call for replace ?

select  replace(rtrim(xmlagg(xmlelement(e,id,',').extract('//text()') order by id).GetClobVal(),','),''','''') as Correct_one,

        rtrim(xmlagg(xmlelement(e,id,',').extract('//text()') order by id).GetClobVal(),',') as Wrong_one

from (select level||'''s' as id from dual connect by level < 10)

But the problem is I dont know what I get in my actual data for eg: '>' or '<' symbols. Then how do I dynamically replace it ?

Version:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

Regards,

Ranagal

This post has been answered by Paulzip on May 14 2019
Jump to Answer
Comments
Post Details
Added on May 14 2019
9 comments
1,747 views