background image
<< Modifying Triggers | Dropping Triggers >>
<< Modifying Triggers | Dropping Triggers >>

Compiling Triggers

Creating and Using Triggers
Using Triggers 5-9
When you need to disable all triggers on a particular table, you must use the statement
ALTER TABLE ... DISABLE ALL TRIGGERS
. To re-enable all the triggers for the
table, use the statement
ALTER TABLE ... ENABLE ALL TRIGGERS
.
Example 5­11
shows how to temporarily disable all triggers that are defined on a
particular table.
Example 5­11 Disabling All Triggers on a Table
ALTER TABLE evaluations DISABLE ALL TRIGGERS;
Example 5­12
shows how to re-enable all triggers that are defined on a particular
table.
Example 5­12 Enable All Triggers on a Table
ALTER TABLE evaluations ENABLE ALL TRIGGERS;
Compiling Triggers
A trigger is fully compiled when the
CREATE TRIGGER
statement is executed. If a
trigger compilation produces an error, the DML statement fails. To see the relevant
compilation errors, use the
USER_ERRORS
view.
Example 5­13
shows how to determine which trigger errors exist in the database.
Example 5­13 Displaying Trigger Compilation Errors
SELECT * FROM USER_ERRORS WHERE TYPE = 'TRIGGER';
Once a trigger is compiled, it creates dependencies on the underlying database objects,
and becomes invalid if these objects are either removed or modified so that there is a
mismatch between the trigger and the object. The invalidated triggers are recompiled
during their next invocation.
Example 5­14
shows how to determine the dependencies triggers have on other
objects in the database.
Example 5­14 Displaying Trigger Dependencies
SELECT * FROM ALL_DEPENDENCIES WHERE TYPE = 'TRIGGER';
To re-compile a trigger manually, you must use the
ALTER TRIGGER ... COMPILE
statement, as shown in
Example 5­15
.
Example 5­15 Displaying Trigger Compilation Errors
ALTER TRIGGER update_name_view_trigger COMPILE;
See Also:
Oracle Database PL/SQL Language Reference for details about
enabling triggers
Oracle Database PL/SQL Language Reference for details about
disabling triggers