Home Forums SQL Server 2008 T-SQL (SS2K8) Logic problem in "SET [Quantity_Remaining] = [Quantity_Remaining] - 1" RE: Logic problem in "SET [Quantity_Remaining] = [Quantity_Remaining] - 1"

  • That last part makes sense...

    I'm thinking an "IF" condition on transaction_type may be a step in the right direction (?):

    USE [TrackIT]

    GO

    CREATE TRIGGER [dbo].[trDecrementBulkPurchases]

    ON [dbo].[tblTransactions]

    AFTER INSERT

    AS

    BEGIN

    IF Transaction_Type = 'From Bulk Assignment'

    UPDATE [TrackIT].[dbo].[tblBulkPurchases]

    SET [Quantity_Remaining] = [Quantity_Remaining] - 1

    WHERE PO_Number IN (SELECT [PO_Number] FROM [tblTransactions])

    END IF

    END

    GO

    -- there are some syntax issues of course