Opinions on triggers

  • Here's an example of how I've used triggers in the past. We wrote an order entry system that had an EAV design for attributes. The design, this was over 10 years ago so I may not get everything right. This was for a paper mill that made large rolls of paper that was sold to converters and we also did some converting to sheets. So forms would be rolls and sheets and types would be Towel, Fine Paper, etc... The attributes for rolls and sheets are very different so we had Product Type Attributes and Product Form Attributes that the ordered product would inherit. So as the order was entered a product would be selected and, based on the type, the type attributes with any defaults would be loaded into the product attributes table by a trigger, and then when the form was selected a trigger would load the product form attributes into the product attributes table. Since the UI was a wizard this worked great as the next screen would be a list of the product attributes so the values for these attributes could be entered.

    Triggers aren't the only way to do this but this worked well for us.

  • I also used triggers once to separate out replication. We had a Sales database and an accounting database. We did this:

    Sales.dbo.SalesOrder table

    |-> trigger to insert into Sales.dbo.NewSales

    replication from Sales.dbo.NewSales to Accounting.dbo.NewSales

    Accounting.dbo.NewSales

    |-> trigger to add data to Accounting.dbo.SomeTable

    This was so if we had to drop replication, we wouldn't be moving all of the SalesOrder table, or interrupting operations.

Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply