数据库触发器求助

  • y
    yancya
    不是开发
    自己摸索着写了一个触发器
    帮忙看下这样使用会有问题么
    1. ALTER trigger [dbo].[test5] on [dbo].[ICStockBill]
    2. FOR insert
    3. as
    4. DECLARE @A INT
    5. select @A = FInterID FROM inserted where ftrantype = 1
    6. SET NOCOUNT ON
    7. begin
    8. IF EXISTS (SELECT 1 FROM inserted WHERE FHeadSelfA0148 = '990348' or FHeadSelfA0148= '990346')
    9. update ICStockBill
    10. set
    11. FHeadSelfA0149 = '0'
    12. where FInterID = @A

    13. ELSE IF EXISTS (SELECT 1 FROM inserted WHERE FHeadSelfA0148 = '990347' )
    14. update ICStockBill
    15. set
    16. FHeadSelfA0149 = '13'
    17. where FInterID = @A
    18. END

    19. begin update
    20. t2 set t2.FEntrySelfA0173 = t1.FHeadSelfA0149 from
    21. icstockbill t1 join icstockbillentry t2 on t1.finterid=t2.finterid
    22. and t1.ftrantype = 1 where t2.FInterID = @A
    23. end

    24. begin update ICStockBillEntry
    25. set
    26. FAuxPrice=FPurchaseAmount/(FQty*(FEntrySelfA0173/100+1)),
    27. FAmount=FPurchaseAmount/(FQty*(FEntrySelfA0173/100+1))*FQty,
    28. FEntrySelfA0170=(FPurchaseAmount/(1+FEntrySelfA0173/100))*FEntrySelfA0173
    29. from ICStockBillEntry
    30. where FInterID = @A
    31. end
    复制代码
  • R
    Romney
    2021年了还有人用数据库触发器?
  • y
    yancya
    没钱找开发 我自己对付着弄一下能用就行
  • y
    yancya
    顶一下。 iOS fly ~
  • m
    manhere
    严禁使用数据库高级特性
  • y
    yancya
    额 不明白。。。我以前用游标 我试了下不用游标一样效果