触发更新

时间:2016-05-12 05:43:52

标签: sql sql-server triggers

事先izvenyayus为代码中的污垢但朋友不能,一般来说,有一个触发器

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER Trigger [dbo].[Need] 
ON [dbo].[Bill of materials]
FOR INSERT 
AS 
    Declare @a int;
    Declare @b int;
    Declare @C int;
    Declare @v int;
    Declare @q int;

    select @C = Material @v = the Quantity in stock from Vedomostithe 

    select @a = sum(amount) 
    from Bid 
    where Status = 'In transit' 
      and Application.Part name = @Name 
    group by details 

    select @b = number 
    from the Plan 
    where the Plan.ID = @from 

    select @q = Name parts 
    from the arrival Journal

    update Bill of materials 
    set a = @b - isnull(@a, 0) - @v 
    where the Bill of materials .Material = @q

他的任务是通过简单的公式计算净利润

Net demand = Number plan - number (only those which more on the way) - quantity in stock

问题是,当净需求必须为零时,需要净值需要其他部分

0 个答案:

没有答案