CREATE TRIGGER [update_ICS_gongshi] --自定义触发器的名称
ON [dbo].[ICStockBillEntry] --出入库单据分录表 此处为表名,触发器的表名,意为在哪个表创建触发
FOR INSERT,UPDATE,DELETE --触发类型:INSERT、UPDATE、DELETE;分别意为插入时、更新时、删除时触发,依据英文意思理解即可
AS
SET NOCOUNT ON
DECLARE @FICMOInterID int; --声明变量:FInterID 生产任务单内码
select @FICMOInterID = MAX(FICMOInterID) --取当前插入或更新单据的生产任务单内码赋值给@FRoutingID
from (select FICMOInterID FROM inserted union all select FICMOInterID FROM deleted)a
BEGIN
/*更新生产任务单工时*/
update ICMO --更新生产任务单工时
set FHeadSelfJ01108 = FHeadSelfJ01107 * (FAuxQty - FAuxStockQty)
from ICMO
where FInterID = @FICMOInterID
END
drop trigger [update_ICS_gongshi]
select * from ICStockBill
where FTranType = 2 --单据类型2,产品入库单'139764'
and FCancellation != 0
FOrgBillInterID --原单内码
select * from ICStockBillEntry
where FICMOBillNo = 'JT21897-3(WJW-14310-SJT7)' --生产任务单号
and FFatherProductID = '' --产品内码
and FICMOBillNo = '' --生产任务单号
and FICMOInterID = '' --任务单内码
and FInStockID = '' --入库单内码
and FSCBillInterID = '' --原单内码
and FSCBillNo = '' --原单单号
and FSourceInterId = '' --源单内码'87646'
and FSourceTranType = '' --源单类型
产品入库更新生产任务单工时
最新推荐文章于 2021-03-13 08:30:05 发布