表单触发器

本文介绍了两个数据库触发器的使用,第一个用于在大数据背景下控制审核单据并更改物料单价,当特定条件满足时更新物料价格记录。第二个触发器则在单据保存时进行权限检查,防止在查询帐套中保存数据。
摘要由CSDN通过智能技术生成

控制审核单据 更改物料单价

ALTER TRIGGER [dbo].[ICStockBill_updateprice]
            ON [dbo].[ICStockBill]
FOR update
AS

 SET NOCOUNT ON

 if exists (select 1 from  deleted  where  ftrantype =1 and frob=1 and isnull(fcheckerid,0)=0)
 begin
     if exists (select 1 from  inserted  where  ftrantype =1 and frob=1 and isnull(fcheckerid,0)>0)
     begin

      declare @fitemid int
      declare @fprice decimal(18, 4)
      declare @forderprice decimal(18, 4)
  
      select @fitemid=tt.fitemid,@fprice=tt.fprice,@forderprice=t1.forderprice from icstockbillentry tt
      left join t_ICItemCore t1 on tt.fitemid=t1.fitemid
      where finterid in (select finterid from inserted) 

      INSERT INTO zt_wg_updatepricetime(fitemid,forderprice_old,forderprice_new,ftype,fupdatetime)
      VALUES(@fitemid,@forderprice,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值