In my Oracle 11gR2 database I a writing this query (attached in code).
But I get this error:
I get error: ORA-01489: result of string concatenation is too long.
I put a substr function to limit the LISTAGG value to 2000 but still I get the error.
This query works when the concatenated length is not huge...
Is there any way to fix it?
SELECT x.f1 as f1, substr((LISTAGG(x.f1, ', ') WITHIN GROUP(ORDER BY x.id)), 1, 2000) as f2_list
FROM (SELECT t.id as id, t.f1 as f1, t.f2 as f2
FROM MYTAB t,
GROUP BY f1