Subject Re: [ib-support] Triggers
Author Helen Borrie
At 03:51 PM 04-03-02 +1300, you wrote:
>When a new user is added does he have the right to fire the triggers or
>he must be assigned the rights?

If he has rights to the table, then he has rights to its triggers.


>Is it possible to deactive a trigger inside a transaction and enable it
>after commiting or rollback, so that other users are still able to fire
>them?

As long as the trigger is disabled, NO users' work will fire it. DDL (such
as ALTER TRIGGER) does not take effect until it is committed, so the flow
would go like this:

start a transaction
submit ALTER TRIGGER
commit // won't happen if any user is using the table
if successful:
start another transaction
// disabled triggers won't fire for any user's transaction
do the stuff that requires the triggers disabled
commit

start another transaction
re-enable the triggers if no trans is using the table
commit if possible

Also realise that, if you are not using Firebird, your database will become
unavailable after 255 instances of ALTER TRIGGER and you will have to back
up and restore in order for it to become accessible again.

Architecturally, it is not good practice to use DDL to condition behaviour
at the client layer, even though the Firebird enhancement is available. It
is eminently preferable to build conditional logic into the trigger.

regards,
Helen

All for Open and Open for All
Firebird Open SQL Database ยท http://firebirdsql.org
_______________________________________________________