做完了一个项目 在导出excel的时候 报错
错误是 ORA-06502:PL/SQL 数字或值错误:字符串缓冲区太小 和 ORA-06521:在“WMSYS.WM_CONCAT_IMPL”,LINE 30
sql语句是
SELECT DISTINCT FW.FWBH,FW.FWLX,FW.MGS,
(SELECT MIN(SH_CLGCJL.CZSJ)FROM SH_CLGCJL, SH_BDSHFU
WHERE SH_CLGCJL.FWBH = SH_BDSHFU.PK1 AND SH_BDSHFU.PK1 = '1761A7C2E5855DF1CADDC3D445BC999D'
GROUP BY SH_CLGCJL.FWBH) AS CZSJ,
(SELECT MAX(SH_CLGCJL.FKSJ)
FROM SH_CLGCJL, SH_BDSHFU
WHERE SH_CLGCJL.FWBH = SH_BDSHFU.PK1 AND SH_BDSHFU.PK1 = '1761A7C2E5855DF1CADDC3D445BC999D'
GROUP BY SH_CLGCJL.FWBH) AS FKSJ,
FW.LXRBH,FW.LXFS,
(SELECT S3.CNNAME AS FW_SLR FROM SH_CLGCJL JL LEFT JOIN SH_USER S3 ON (S3.ENNAME = JL.FW_SLR)
WHERE FWBH = '1761A7C2E5855DF1CADDC3D445BC999D' AND ROWNUM = 1) AS FW_SLR,
FW.NR,FW.BYZD2,
S2.CNNAME AS BYZD3,
(SELECT REPLACE(WMSYS.WM_CONCAT(M.JD), ',', '||') RESULT
FROM (SELECT REPLACE(WMSYS.WM_CONCAT(SH_CLGCJL.FKSJ || ' ' ||S5.CNNAME || ' ' ||SH_CLGCJL.BYZD1),',',
' || ') JD FROM SH_CLGCJL LEFT JOIN S_USER S5 ON (S5.ENNAME =SH_CLGCJL.FW_SLR)
WHERE SH_CLGCJL.FWBH ='1761A7C2E5855DF1CADDC3D445BC999D' AND S5.ENNAME = SH_CLGCJL.FW_SLR
GROUP BY SH_CLGCJL.FKSJ) M) AS BYZD1,
FW.FKYJ,
FW.BZ,
FW.PK1
FROM SH_BDSHFU FW
LEFT JOIN S_DIC S2 ON (S2.TYPE1 = '完成情况' AND S2.ENNAME = FW.BYZD3),
SH_CLGCJL JL
WHERE FW.PK1 = JL.FWBH
AND FW.PK1 = '1761A7C2E5855DF1CADDC3D445BC999D'
AND FW.BYZD3 = '01'
这个怎么解决那个缓冲的大小问题呢 网上找了好多都不能实现 谁能帮忙解决一下谢了
------解决方案--------------------
WMSYS.WM_CONCAT(M.JD)
WMSYS.WM_CONCAT(SH_CLGCJL.FKSJ || ' ' ||S5.CNNAME || ' ' ||SH_CLGCJL.BYZD1)
注意观察你的这两句里的输入内容,有点问题,当输入的字符长度超过4000时,就会出现字符串缓冲区太小。
------解决方案--------------------
WMSYS.WM_CONCAT返回varchar2,最多4000个字节,所以你只能想办法减少查询记录数,这样拼接起来字符串长度小于4000,
或者自己写个函数,看看这个
http://blog.163.com/leo_wuya/blog/static/44451843201123023659183/