What I'm trying to achieve is concatenating strings up to a length of 10 with carriage return. If the row goes over length 10 then it should be added to the next concatenation row.
Example, having the following data set
SELECT '0123' col FROM DUAL
UNION ALL
SELECT '45 67' FROM DUAL
UNION ALL
SELECT '89A' FROM DUAL
UNION ALL
SELECT 'BC' FROM DUAL
UNION ALL
SELECT 'DEFGHI' FROM DUAL
What I expect for the result
SELECT '0123
45 67' col FROM DUAL
UNION ALL
SELECT '89A
BC' FROM DUAL
UNION ALL
SELECT 'DEFGHI' FROM DUAL
I'm running oracle 12.1 and I don't want to do it in PLSQL due to performance reasons. I'm dealing with higher numbers. I posted the simple example so it'll be easier. My end goal is to use listagg somehow where each row has a max of 4k chars


chr(10)alone, which is standard in Oracle and is the line terminator in Unix? Orchr(13) || chr(10)as in DOS/Windows? Or something else? 2. Do you need to add a newline at the end of the string too? 3. What is your Oracle version? 4. What should happen if an input string (in a single row) is LONGER than the limit already? Perhaps in your real use case (4000, not 10) that doesn't happen, but it may still be an issue if you must add a newline at the end (see earlier question).