Why would I use triggers?

There are many reasons to use triggers. If you have a table which keeps a log of messages you may want to have a copy of them mailed to you if they are urgent. If there were no triggers you would have some solutions, though they are not as elegant. You could modify the application(s) logging the messages. This means that you might be redundantly coding the same thing in every application that logs messages.

Alternatively you might decide to search the message log every so often and see what is new. This involves a trade off of how many resources you wish to devote to checking if anything happened versus the delay to see anything news.

Triggers solve these problems nicely. One program will see every message that is entered, and if it is urgent can forward it to you. If you decide on other criteria you only need change that program, not every application. Also this program only uses resources when an insert is taking place, and then it delivers immediately.


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.