成本计算提示:merge语句试图多次更新或删除同一行,目标...
金蝶云社区-刘月强
刘月强
2人赞赏了该文章 2,365次浏览 未经作者许可,禁止转载编辑于2018年04月05日 16:30:51


/*
成本计算提示错误
merge语句试图多次更新或删除同一行,目标行与多个源行匹配时会出现这种情况……
*/
--生产订单与入库单行号未匹配行
SELECT t2.FBILLNO,T0.FMOBILLNO,T0.FMOENTRYSEQ,T1.FSEQ,T2.FDATE,T3.FBILLNO,T0.FSEQ,t0.fentryid FROM T_PRD_INSTOCKENTRY T0 INNER JOIN T_PRD_MOENTRY T1
ON T0.FMOID = T1.FID AND T0.FMOENTRYID = T1.FENTRYID
INNER JOIN T_PRD_MO T2 ON T2.FID = T1.FID
INNER JOIN T_PRD_INSTOCK T3 ON T3.FID = T0.FID
WHERE T0.FMOENTRYSEQ<>T1.FSEQ

--查询生产入库单错误行号信息,根据上面查询结果进行修正
select FMOENTRYSEQ,* from T_PRD_INSTOCKENTRY where fentryid in
(
SELECT t0.fentryid FROM T_PRD_INSTOCKENTRY T0 INNER JOIN T_PRD_MOENTRY T1
ON T0.FMOID = T1.FID AND T0.FMOENTRYID = T1.FENTRYID
INNER JOIN T_PRD_MO T2 ON T2.FID = T1.FID
INNER JOIN T_PRD_INSTOCK T3 ON T3.FID = T0.FID
WHERE T0.FMOENTRYSEQ<>T1.FSEQ)

--生产订单与入库单行号未匹配
SELECT t2.FBILLNO,T0.FMOBILLNO,T0.FMOENTRYSEQ,T1.FSEQ,T2.FDATE,T3.FBILLNO,T0.FSEQ,t0.fentryid FROM T_PRD_morptENTRY T0 INNER JOIN T_PRD_MOENTRY T1
ON T0.FMOID = T1.FID AND T0.FMOENTRYID = T1.FENTRYID
INNER JOIN T_PRD_MO T2 ON T2.FID = T1.FID
INNER JOIN T_PRD_morpt T3 ON T3.FID = T0.FID
WHERE T0.FMOENTRYSEQ<>T1.FSEQ

--生产汇报单错误行号信息,根据上面查询结果进行修正
select FMOENTRYSEQ, * from T_PRD_morptENTRY where fentryid in
(
SELECT t0.fentryid FROM T_PRD_morptENTRY T0 INNER JOIN T_PRD_MOENTRY T1
ON T0.FMOID = T1.FID AND T0.FMOENTRYID = T1.FENTRYID
INNER JOIN T_PRD_MO T2 ON T2.FID = T1.FID
INNER JOIN T_PRD_morpt T3 ON T3.FID = T0.FID
WHERE T0.FMOENTRYSEQ<>T1.FSEQ)