ORA-06502: PL/SQL: numeric or value error: character string buffer too small

oracle执行报错

ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "WMSYS.WM_CONCAT_IMPL", line 30

错误原因

因为sql中使用了wm_concat做字符串连接,但是当连接的字符串结果大于4000时,就会报上面的错误
由于oracle对字符串长度有限制,长度不能超过4000

解决方法

substr(xmlagg(xmlparse(content 字段名||',' wellformed)).getclobval(),0,length(xmlagg(xmlparse(content 字段名||',' wellformed)).getclobval())-1) 别名

主要使用了xmlall,另外之所以使用substr是因为,如果不用的话后面会多一个,

posted @ 2022-11-25 14:59  镇魂帆-张  阅读(1179)  评论(0编辑  收藏  举报