How to tweak LISTAGG to support more than 4000 character in select query?

You should add GetClobVal and also need to rtrim as it will return delimiter in the end of the results.

SELECT RTRIM(XMLAGG(XMLELEMENT(E,colname,',').EXTRACT('//text()') 
  ORDER BY colname).GetClobVal(),',') from tablename;

Leave a Comment