Oracle字符串拼接过长问题

0
Hello各位专家,

我需要将类似如下数据拼接起来:

Capture.JPG



希望得到如下的两列结果:
week   MondayTuesdayWednesdayThursdayFridaySaturdaySunday
 
查询语句如下:
select aa,listagg(to_clob(cc),'') within group (order by  bb) as txt from test_table group by aa

实际环境中文本很长,查询会产生错误:
ORA-01489: result of string concatenation is too long
01489. 00000 -  "result of string concatenation is too long"
*Cause:    String concatenation result is more than the maximum size.
*Action:   Make sure that the result is less than the maximum size.

原因基本上清楚了,就是拼接后的文本长度超过4000字符,那么如何将过长的结果截断呢?查了网上(渡娘+谷歌),都没有相关的解答,还请专家们帮忙看看,想想法子,非常感谢!
已邀请:
0

大连海龙 - 70后,生产ERP,SSIS/SSRS 2016-02-26 回答

谢谢老头子,如果还用我原来的方法,如何截断多于4000的查询结果呢?
1

老头子 - 专注是唯一的捷径 2016-02-26 回答

select t.OWNER,xmlagg(xmlparse(content t.OBJECT_NAME || ',' wellformed) ORDER BY t.OBJECT_NAME)
  from dba_objects t
 group by t.OWNER

要回复问题请先登录注册