Subject Re: [firebird-support] Re: Are stored procedures in triggers a good idea?
Author Daniel L. Miller
Adam wrote:

>Yes it is a good thing to do.
>Forgetting the generator protection specifics that a lot of people
>disagree with, calling a SP from a trigger is actually quite helpful.
>What you will find is that in many cases, the before insert and before
>update triggers contain a significant amount of common code. If you
>duplicate the code in both triggers, then find a bug you will have to
>remember to fix it twice. If however you called a SP that was the
>common code, you could simply fix the SP. Taken further still, often
>changes to multiple tables need to execute the same code.
>Now the caveat.
>SPs will make you stop thinking about what you are doing. If you
>update tableA, the before update trigger(s) will be run on it. Lets
>say this trigger calls SP_a. You may not remember that SP_a actually
>updates tableB which in turn will force the before update trigger(s)
>to run on tableB. If you are not careful, the update trigger on tableB
>might try and update tableA and that is not good.
Point well taken. My intent for trigger-called SP's is to use non-table
modifying SP's (other than perhaps changing a generator value), and use
the return value in the triggers.