本站使用了 Pjax 等基于 JavaScript 的开发技术,但您的浏览器已禁用 JavaScript,请开启 JavaScript 以保证网站正常显示!

触发器 - 委外订单审核时修改委外投料单的损耗率

实际上是在委外投料单insert之后的触发;在K3wise环境下;

相关表

select * from PPBOM
select * from PPBOMEntry --FScrap
select * from t_ICItem 

创建触发器

alter trigger tr_ReScrap
on PPBOMEntry
after insert
as
begin
    declare @FInterID int 
    select @FInterID = FInterID from inserted
    if OBJECT_ID('tempdb..#row') is not null        
    drop table #inv
    select th.FInterID,
        th.FBillNo,
        th.FTranType,
        th.FType,
        te.FDetailID,
        te.FEntryID,
        te.FItemID,
        te.FScrap,
        ti.FNumber 
        into #row
        from PPBOM th
        left join PPBOMEntry te on th.FInterID = te.FInterID
        left join t_ICItem ti on te.FItemID = ti.FItemID
        where ti.FNumber like '10.%' and th.FType = '1067' and th.FInterID = @FInterID

    if exists (select * from #row)

    update t1 set t1.FScrap = 0,FNote = 'bom损耗已修改11' from PPBOMEntry t1, #row t2 where t1.FDetailID = t2.FDetailID

end

Offer

推广

 继续浏览关于 触发器 的文章

 本文最后更新于:2020/05/21 12:58:25,可能因经年累月而与现状有所差异,有任何疑问可以随时与258771198@qq.com沟通,邮箱永久有效

 引用转载请注明:manacode(码扣) > SQL,ERP > 触发器 - 委外订单审核时修改委外投料单的损耗率