title: Mysql/adventureworks database/trigger question
body: <p>Good afternoon I have been having some trouble trying to understand this question in class.The purpose of this assignment is to add parameters around data entry through triggers that are launched when specific conditions are met.</p>
  
  <p>Due to warehousing limitations, inventory over 800 units needs to be sent to an external storage site and tracked separately. You have been asked to monitor when an update will exceed this boundary so it can be addressed in production meetings.
  Write a trigger titled "tgrExcessInventory" for the Production.ProductInventory table to ensure the quantity can never exceed 800 units. This is step one. 
  Modify the trigger created in step 1 to execute its check code only if the Quantity column is updated. I successfully created the trigger but I am having trouble understanding how to modify it? This is what I have so far. I Have seen a few other post on here similar to this question, but I haven't seen any with the modification done to it. I feel it'something small im missing. From my understanding I need to write an alter statement? </p>
  
  <pre><code>CREATE TRIGGER tgrExcessInventory
  on Production.ProductInventory
  FOR UPDATE
  AS
  IF EXISTS
      (SELECT 'True'
      FROM Inserted i
      JOIN Deleted d
              ON i.productID = d.ProductID
              AND i.locationID = d.LocationID
              WHERE (d.quantity + i.quantity) &gt;= 800 OR 
              i.quantity &gt;=800
  
      )Begin
      RAISERROR('Cant increase supply where units would be over 800 
      units',16,1)
              ROLLBACK TRAN
      END
  </code></pre>
  
  <p>Then I did the alter function</p>
  
  <pre><code>      ALTER TRIGGER [Production].[tgrExcessInventory]
        on [Production].[ProductInventory]
        FOR UPDATE
        AS
        IF EXISTS
        (SELECT 'True'
        FROM Inserted I
         JOIN Deleted D
              ON i.Quantity = d.quantity
              AND i.Quantity = d.Quantity
              WHERE (d.quantity + i.quantity) &gt;= 800 OR 
              i.quantity &gt;=800
  
      )Begin
      RAISERROR('Cant increase supply where units would be over 800 units',16,1)
              ROLLBACK TRAN
      END
  </code></pre>
  
  <p>Seems to work? I believe i did this right any tips would be appreciated thanks for your time </p>