UPDATE T_MRP_SUPPLYDATA1 u1
SET (fbasesupplyqty) =
(SELECT DISTINCT u1.fbasetotalqty - v1.fbaseqty
FROM (SELECT t1.fsupplyformid,
t1.fsupplyinterid,
t1.fsupplyentryid,
sum(t1.fbaseqty) FBASEQTY
FROM t_pln_reservelinkentry T1
INNER JOIN t_pln_reservelink T2
ON t1.fid = t2.fid
WHERE (t2.FRESERVETYPE <> '2')
GROUP BY t1.fsupplyformid,
t1.fsupplyinterid,
t1.fsupplyentryid) V1
WHERE ((u1.frelationformid = v1.fsupplyformid AND
u1.frelationinterid = v1.fsupplyinterid) AND
u1.frelationentryid = v1.fsupplyentryid))
WHERE EXISTS (SELECT DISTINCT 1
FROM (SELECT t1.fsupplyformid,
t1.fsupplyinterid,
t1.fsupplyentryid,
sum(t1.fbaseqty) FBASEQTY
FROM t_pln_reservelinkentry T1
INNER JOIN t_pln_reservelink T2
ON t1.fid = t2.fid
WHERE (t2.FRESERVETYPE <> '2')
GROUP BY t1.fsupplyformid,
t1.fsupplyinterid,
t1.fsupplyentryid) V1
WHERE ((u1.frelationformid = v1.fsupplyformid AND
u1.frelationinterid = v1.fsupplyinterid) AND
u1.frelationentryid = v1.fsupplyentryid))
发现在跑MRP之前先清除冲突,再跑MRP就没有问题,
清除冲突后T_MRP_SUPPLYDATA1会drop掉,
所以下次MRP能够正常执行