Subject | Re: Trigger, check whether a cascade or user caused action |
---|---|
Author | thp_pkmi |
Post date | 2013-06-01T05:26:55Z |
--- In firebird-support@yahoogroups.com, "firebirdsql" <firebirdsql@...> wrote:
Actually I have a trick to distinguish user update from cascade update. I always put an extra field in my table called Sig (or Tag, or whatever..), in my application I always increase Sig by 1 on every post update, then in the before update trigger I can detect:
if (new.Sig is distinct from old.Sig) then
...
and finally at the end of the trigger I restore the Sig:
new.Sig= old.Sig;
So far it's working fine, I also wonder if there is a minus in this mechanism, would somebody please give an advice or review on this ?
Thanks.
Regards,
Tjioe Hian Pin
>I posted an almost similar case today, in my case I just want to distinguish cascade delete from user/regular delete.
> I have an after update/delete trigger and would like to know if the trigger was triggered by a cascade update/delete OR a user. Is this possible?
>
Actually I have a trick to distinguish user update from cascade update. I always put an extra field in my table called Sig (or Tag, or whatever..), in my application I always increase Sig by 1 on every post update, then in the before update trigger I can detect:
if (new.Sig is distinct from old.Sig) then
...
and finally at the end of the trigger I restore the Sig:
new.Sig= old.Sig;
So far it's working fine, I also wonder if there is a minus in this mechanism, would somebody please give an advice or review on this ?
Thanks.
Regards,
Tjioe Hian Pin