2 Day Developer > Using Triggers > Designing Triggers > Guidelines For Triggers
Guidelines For Triggers |
Previous |
Next |
Use the following guidelines when designing triggers:
Use triggers to guarantee that when a specific operation is performed, related actions are performed.
Do not define triggers that duplicate features already built into Oracle Database XE. For example, do not define triggers to reject bad data if you can do the same checking through declarative integrity constraints.
Limit the size of triggers. If the logic for a trigger requires more than 60 lines of PL/SQL code, it is better to include most of the code in a stored procedure, and call the procedure from the trigger. The size of the trigger cannot be more than 32K.
Use triggers only for centralized, global operations that should be fired for the triggering statement, regardless of which user or database application issues the statement.
Do not create recursive triggers. For example, creating an AFTER
UPDATE
statement trigger on the employees
table that will then issue an UPDATE
statement on the same employees
table, will cause the trigger to fire recursively until it has run out of memory.
Use triggers on the database judiciously. They are executed for every user, every time the event occurs on which the trigger is created.