Subject | Trigger Classes |
---|---|
Author | Jim Starkey |
Post date | 2001-10-15T20:53:49Z |
While I'm in the area, I thought I'd share a solution to the
problem of programatic activation/deactivation of triggers.
Netfrastructure has a trigger happy customer who desired
to deactivate selected triggers during certain system management
operations but without taking the database generally off line.
The Interbase DDL to set triggers inactive was too crude a
tool since that would affect all users, not just his system
administration procedures. I came up with a simple, elegant
(well, I think so), lightweight solution that seems to answer
nicely.
The mechanism consists of another clause on trigger definitions
( class <trigger_class_name> ) and two two DDL systems
"enable <trigger_class_name>" and "disable <trigger_class_name>".
Yes, a trigger may be a member of an arbitrary number of classes.
The disable statement disables triggers of the given name for
either the duration of connection or until the trigger class
is explicitly enabled with the enable trigger class statement.
Trigger classes are not explicitly declared, just used.
The implementation is dirt cheap. The attachment object keeps
a list of disabled class names. Before a prospective trigger
fires, it loops through the set of disabled classes to see
if it has been turned off.
Jim Starkey
problem of programatic activation/deactivation of triggers.
Netfrastructure has a trigger happy customer who desired
to deactivate selected triggers during certain system management
operations but without taking the database generally off line.
The Interbase DDL to set triggers inactive was too crude a
tool since that would affect all users, not just his system
administration procedures. I came up with a simple, elegant
(well, I think so), lightweight solution that seems to answer
nicely.
The mechanism consists of another clause on trigger definitions
( class <trigger_class_name> ) and two two DDL systems
"enable <trigger_class_name>" and "disable <trigger_class_name>".
Yes, a trigger may be a member of an arbitrary number of classes.
The disable statement disables triggers of the given name for
either the duration of connection or until the trigger class
is explicitly enabled with the enable trigger class statement.
Trigger classes are not explicitly declared, just used.
The implementation is dirt cheap. The attachment object keeps
a list of disabled class names. Before a prospective trigger
fires, it loops through the set of disabled classes to see
if it has been turned off.
Jim Starkey