wm_concat 函数报错:ora06502-character string buffer to small

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_28356739/article/details/88626952

有朋友l开发过程中用到wm_concat 函数拼接两个字段,写完sql运行时报错:

ora06502-character string buffer to small

这个wm_concat函数明明是把要拼接得两个字段结果转换成clob字段,而且拼接得两个字段合计最长才7000多字节,比clob得32767长度小的多。其实这个函数虽然拼接后的结果时clob类型,但是最大长度也不能超过4000,而且在12c,wm_concat函数已经弃用,Oracle官方
也不再推荐使用这个函数,而是用listagg函数:

listagg(合并字段,'连接符号') within group (order by 排序字段)

如果要拼接字符超过4000得函数,可以使用下面得XML函数:

xmlagg(xmlparse(content 合并字段||',' wellformed) order by 排序字段).getclobval() 

分组的话在sql后面使用group by 进行分组

猜你喜欢

转载自blog.csdn.net/qq_28356739/article/details/88626952