Aggregating a large number of objects into one string can lead to ORA-01489, due to the 4000 character limit of the listagg function.
As an example, let’s try to concatenate all user names in the database (referred to as “object”).
select listagg(object, ',') within group (order by user_id) objects from ( select user_id, username object from dba_users ) ;
ORA-01489: Das Ergebnis der Zeichenfolgenverkettung ist zu lang
01489. 00000 — “result of string concatenation is too long”
*Cause: String concatenation result is more than the maximum size.
*Action: Make sure that the result is less than the maximum size.
The workaround is to use the xmlagg function.
select rtrim(xmlagg(xmlelement(e,object,',').extract('//text()') order by user_id).GetClobVal(),',') objects from ( select user_id, username object from dba_users ) ;

The structure of the sql stays the same.
Du muss angemeldet sein, um einen Kommentar zu veröffentlichen.