我正在尝试按如下方式使用 listagg 函数,但得到 ORA-01489: result of string concatenation is too long。
SELECT LOCATIONID, LISTAGG(TO_CHAR(XPOSITION||','||YPOSITION), ',') WITHIN GROUP (ORDER BY SEQUENCENUMBER) ords
FROM POSITIONPOINTS
GROUP BY LOCATIONID
HAVING COUNT(SEQUENCENUMBER) = 20;
当我尝试在 Oracle Sql Developer 中运行它时,它会显示前 1550 行,然后报告 ORA-01489 错误。总共应返回 2612 行,所有 ords 值的长度约为 440 个字符。Sql Developer 返回的行之一的示例是:
22372682 410434.801,551142.885,410434.784,551142.875,410439.801,551141.922,410439.991,551141.795,410439.293,551138.303,410438.531,551137.668,410429.768,551134.302,410427.228,551133.159,410426.212,551132.143,410425.196,551129.667,410421.957,551114.3,410414.972,551081.28,410413.639 ,551076.136,410412.94,551073.66,410412.94,551072.326,410413.639,551071.628,410415.798,551070.612,410416.369,551069.469,410416.877,551068.834,410433.23,551061.795
PositionPoints 表中有一些 LocationIDs 有超过 20 个条目(最多 254 个),对于这些行,我希望连接的字符串超过 4000 个字符的最大值。但是,如果 count(sequencenumber) = 20,则连接的字符串长度将小于 500。即使对于我使用 HAVING 子句排除的位置,Oracle 是否也在执行连接,并报告这些错误?
我尝试从 Oracle Sql Developer 和 SQL Plus 运行查询。
如果有人能对这个问题有所了解,将不胜感激。
谢谢