3
I made a select with the function LISTAGG
to concatenate a field of my table, however the error is returned:
ORA-01489: the result of string concatenation is too long
Query
(SELECT LISTAGG (pf.pfnomereduzido || ' - ') within
GROUP (
ORDER BY pf.pfid)
FROM fiscal cf
LEFT JOIN pessoa pf ON pf.pfid = cf.contratofiscalpfid
AND cf.contratofiscaldatafinal = '01/01/0001') AS contratofiscalnome
How can I solve?
I don’t know Oracle, but maybe this example can help you: LISTAGG Function: "result of string concatenation is Too long"
– Marconi
Try something like:
(SELECT RTRIM(XMLAGG(XMLELEMENT(E,pf.pfnomereduzido,',').EXTRACT('//text()') ORDER BY pf.pfnomereduzido).GetClobVal(),',') within GROUP ( ORDER BY pf.pfid) FROM fiscal cf LEFT JOIN pessoa pf ON pf.pfid = cf.contratofiscalpfid AND cf.contratofiscaldatafinal = '01/01/0001') AS contratofiscalnome
– Marconi
now the error has changed: FROM keyword not located where expected with the error pointed to the Within GROUP part, must be syntax error...
– Stand Alone
Take this error as a hint that what you’re doing should be done on the client side, not directly in SQL.
– epx
The solution is the path that Marconi posted ... already solved problems as he suggested..
– David