3 ms·
I would argue strongly for that. Triggers should be used rarely. If you need an update to cause some other side effect, make the whole process explicit in a sto
by throwawayboise 5y ago
I would argue strongly for that. Triggers should be used rarely. If you need an update to cause some other side effect, make the whole process explicit in a stored procedure. Triggers can cause suprises and affect transactions in ways that are not always obvious.
- candiddevmike 5y agoMaybe I'm a sadist, but I love triggers. I can easily compare old and new values with them and call functions that also can do comparisons and if statements. Can I do all of this in query? Maybe, but it would look very ugly (especially if I forego the functions too). I only have one app interacting with the database, but if I had more the triggers would enforce data consistency too. Triggers are hard to trace, I'll give you that. I try to test them pretty thoroughly via application unit tests though.
- ranguna 5y agoI 100% agree with you in all points. Triggers are incredibly useful and we shouldn't be scared of them, we should be careful though.