假设我有这张桌子:
ID|Col1|Col2|Col3
1|Text that has 4000 chars|Text2 that has 4000 chars|Text3 that has 4000 chars
2|Text4 that has 4000 chars|Text5 that has 4000 chars|Text6 that has 4000 chars
3|Text7 that has 4000 chars|Text8 that has 4000 chars|Text9 that has 4000 chars
我正在使用 listagg 像这样:
SELECT id,
listagg(col1||col2||col3, ',') within group (order by id)
FROM table;
我遇到了错误:
ORA-01489: result of string concatenation is too long
经过研究,我发现使用 xmlagg 可以解决问题(链接),但后来意识到真正的问题在于 col1、col2 和 col3 的串联,因为它仅限于 4000 个字符,所以执行 xmlagg 仍然会返回相同的错误.
有没有人想出这个?还是没有解决方法?(链接)
更新:
为了清楚起见,我更新了表格上的示例值(供 Kumar 先生理解),我的预期输出应该是这样的:
ID | Agg
1 | Text that has 4000 charsText2 that has 4000 charsText3 that has 4000 chars
2 | Text4 that has 4000 charsText5 that has 4000 charsText6 that has 4000 chars
3 | Text7 that has 4000 charsText8 that has 4000 charsText9 that has 4000 chars
这显然行不通。