|
Is it possible to create an insert update trigger that only executes on the entry of a specific character in a specific column? For example, I have a column in the CLIENT table called SEND_INFO. I want to create a trigger that ONLY fires is an existing client record in that table has their SEND_INFO value updated to 'Y', or when a new client record is inserted into the CLIENT table with the SEND_INFO value of 'Y'. TIA
(comments are locked)
|
|
You can't control whether the trigger fires based on data, but you could of course use logic within the trigger code to branch depending on the value of a column, and in the case of the update test the previous value of the column in the
(comments are locked)
|
|
Personally I would be reluctant to put this sort of logic into a trigger. To be fair I am reluctant to use triggers at all but that's another issue. This could be done using service broker which would disconnect the processes of the data transaction and the logic you want to enforce. If you use a trigger and the logic is flawed it can easily cause locking and blocking because the transaction will be slowed. +1 I'm with you on the trigger - hate them for business logic processing
Aug 25 '11 at 01:19 PM
Kev Riley ♦♦
Triggers are generally fairly poor for business logic processing, but I have found them very useful for logging purposes.
Aug 25 '11 at 01:44 PM
TimothyAWiseman
Yes for logging/auditing. But a definite no for business rules. (Having that battle in present job at the moment.....)
Aug 25 '11 at 01:46 PM
Kev Riley ♦♦
(comments are locked)
|

