I am using Oracle 12.1. I have an ID column on which I am using group by and want to convert values in another column (say NAME) to comma separated string as a CLOB (not VARCHAR2 because of its limitation to 4000 chars).
I tried with LISTAGG function, but it fails as the comma separated string is more than 4000 chars. (There is an improved version of LISTAGG to restrict the overflow, but is not available in Oracle 12.1)
With XMLAGG, it works, but I don't want to use XMLAGG because this particular function is called every 5 seconds and is giving performance issues sometimes and also once in a while "ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT"
What I would like to have is:
- Either need a way to convert column values to comma separated string as a CLOB (without using LISTAGG, XMLAGG)
OR
- I am fine with skipping some column values and use "..." to inform that there are more values. (lets say we can consider only 5 rows instead of all rows for given ID (group by column))
From my answer here, you can write a custom aggregation function to aggregate
VARCHAR2
s into aCLOB
:Then you can do:
OR