Skip to content
Advertisement

Is there a way to continue on the next row after listagg() runs out of space (>4k)?

I would like to change a table that has a number of values per week, to having all values in one row per week. But when I use listagg() I run out of space. I can’t change the maximum string size (ALTER SYSTEM SET max_string_size=extended SCOPE= SPFILE), and I don’t want to truncate the resulting string. However I could just continue on the next line, but I’m not sure how to. For example, if my input is:

Assuming the input file is long enough that it will trip the error :

Then I want a piece of code similar to this:

So that my output will look like this:

Is that possible? Any help is greatly appreciated!

Advertisement

Answer

You can use the analytical function to find the SUM of the length of the strings and then use it for sub-grouping as follows:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement