Oracle 中wmsys.wm_concat拼接字符串,结果过长报错解决

备忘:这个函数最大是4000,根据拼接列的长度,通过限制拼接条数来防止拼接字符串过长错误

--这个情况是从子表中读取出具,这里直接把它当做查询字段处理,在子表中有所有数据
    select info.id,
           (select   wmsys.wm_concat(replace(st1.illegal, ',', ''))
               from ts_acc_standards st1
               where info.acc_id=st1.acc_id   and rownum<=5
               group by st1.acc_id)  as illegal_names
        form ts_info info 
        where info.createuser='user';
--这个情况是,子表是中间表,需要去另一表再去查询
select info.id,
(select wmsys.wm_concat(replace(tam.acc_mode,',','')) from ts_acc_mode tam
left join ts_acc_mode_map tamm on tamm.acc_mode_id=tam.acc_mode_id
where tamm.acc_id=info.acc_id and rownum<=5
    ) as acc_mode
from ts_info info 
where info.id='1';

 

posted @ 2018-03-05 17:10  天涯已可  阅读(3489)  评论(0编辑  收藏  举报