我想按如下方式使用listagg函數,但得到ORA-01489:字符串連接的結果太長。「ORA-01489:字符串連接的結果太長」(字符串很小)
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開發正在返回的行中的一個的一個例子是:
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運行查詢。
如果有人能解決這個問題,請大家感激。
感謝