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!

string aggregation 4000+ characters

spur230Jul 16 2013 — edited Jul 16 2013

Hi All,

I am using Oracle 11.2.0.3.   I was using LISTAGG to generate CSV values for names but  as some of my values are greater than 4000 characters, it is throwing ORA-01489: result of string concatenation is too long.

I tried to used XMLAGG to resolve it . However , it espace special character.  (e.g. & will be escaped to & the xml safe equivalent)

eg

with t as

( SELECT 'A''PPLE' as fname from dual

union all

SELECT 'BALL&'  as fname from dual

union all

select 'CAT!'  as fname from dual )

select  rtrim(xmlagg(xmlelement( e ,   fname,',').extract('//text()') order by fname).GetClobVal(),',') AS NAME from t

RETURNS: A'PPLE,BALL&,CAT!

EXPECTED A'PPLE, BALL&,CAT!

Is it possible to disable escaping while using XMLAGG?

Is there any other recommended way to use string aggregation for more than 4000 characters?

Many Thanks!

This post has been answered by odie_63 on Jul 16 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 13 2013
Added on Jul 16 2013
3 comments
1,839 views