Search code examples
db2maxlengthlistagg

LISTAGG fails with sqlcode=-433


How to overcome from length issue on ListAGG function.

enter image description here


Solution

  • Try the XMLAGG function instead:

    select 
    --length (
    substr(xmlserialize(
    xmlquery('$L/text()' passing XMLAGG(xmlelement(name "a", ','||colname)) as "L") as clob(2M)
    ), 2)
    --)
    from syscat.columns;