单据审核报错:MERGE语句试图多次更新或删除同一行
金蝶云社区-xiewenka
xiewenka
0人赞赏了该文章 1,714次浏览 未经作者许可,禁止转载编辑于2015年04月21日 11:47:20

反审核报错,有些单据审核报错(后台批改过物料单位,另这些单据的物料单位=物料的单位)

--采购申请
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_PUR_ReqEntry t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID
--采购订单
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from t_PUR_POOrderEntry t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID
--采购收料
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_PUR_ReceiveEntry t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID

--采购入库
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_STK_INSTOCKENTRY t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID

--其他出库
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_STK_MISDELIVERYENTRY t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID
--其他入库
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_STK_MISCELLANEOUSENTRY t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID

---销售订单
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_SAL_ORDERENTRY t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID

---发货通知
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_SAL_DELIVERYNOTICEENTRY t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID

---销售出库
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_SAL_OUTSTOCKENTRY t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID
---物料清单
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_ENG_BOMCHILD t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID

---生产订单
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_PRD_MOENTRY t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID

----生产入库
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID
from T_PRD_INSTOCKENTRY t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID
---生产领料
update t1 set t1.FBASEUNITID = t3.FBASEUNITID ,t1.FUNITID=t3.FBASEUNITID,t1.FSTOCKUNITID=t3.FBASEUNITID
from T_PRD_PICKMTRLDATA t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID
---用料清单
update t1 set t1.FUNITID = t3.FBASEUNITID ,t1.FBASEUNITID=t3.FBASEUNITID
from T_PRD_PPBOMENTRY t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID

---查询错误的即时库存数据、修复数据

update t1 set t1.fbaseunitid = t3.fbaseunitid,t1.fsecunitid = t2.fauxunitid ,t1.fstockunitid=t3.fbaseunitid
from T_STK_INVENTORY t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID

--、查询错误的关账余额数据、修复数据

update t1 set t1.fbaseunitid = t3.fbaseunitid,t1.fsecunitid = t2.fauxunitid
from T_STK_INVBAL t1 inner join T_BD_MATERIALSTOCK t2

on t1.FMATERIALID = t2.FMATERIALID

inner join T_BD_MATERIALBASE t3 on t1.FMATERIALID = t3.FMATERIALID

以上是我更新单位的语句,执行后,所有的都改过来,但是有些单据下推出入库单后就报上面的错误