Trigger Designer
This section covers the following topics:
Creating Triggers in Oracle Developer Tools
Use the Trigger Designer to create triggers for tables or views. After you create a new trigger, you can edit the trigger specification using the PL/SQL Code Editor. When you create a trigger, Oracle Database automatically enables it.
You cannot use the Trigger Designer to create the following types of triggers:
-
Procedure calls as triggers
-
Nested column triggers if the new version of the trigger refers to the same view as the old version of the trigger
-
Triggers that use the
:OLD
,:NEW
, or:PARENT
reserved words for row values -
The body of a trigger
-
DDL triggers
However, after you create the trigger, you can modify it in the PL/SQL Code Editor to use these features.
Starting the Trigger Designer
To start the Trigger Designer:
-
If you are creating the trigger on a table, in Server Explorer, open the node for the table. The table node lists nodes for the table's constraints, indexes, and triggers. Right-click the Triggers node and from the menu, select Add Trigger.
-
If you are creating the trigger on a view, in Server Explorer, select and open the view's node. Right-click the Triggers node and from the menu, select Add Trigger.
The Trigger Designer appears similar to the following:
Using the Trigger Designer
In general, use the Trigger Designer to create a new trigger. If you want to create the trigger with functionality not provided in the Trigger Designer, such as adding the OR
REPLACE
keyword, or if you want to edit the trigger later, you can modify the trigger in the PL/SQL Code Editor.
The Trigger Designer has the following controls:
Control | Description |
---|---|
Schema name |
Select from the list of available schemas in which to create the trigger. |
Trigger name |
Enter a name for the trigger. The default name is based on the table for which the trigger was created. |
Occurrence |
Select from the following:
|
Frequency |
Select from the following:
|
Event type |
Check one or more of the following:
Note: You can specify object type, varray, and
|
Columns to update |
Applies only to update triggers. Select from the columns to which the update trigger will apply. |
WHEN condition |
Enter a SQL condition that must be satisfied in order for the trigger to fire. This condition must contain correlation names and cannot contain a query. |
Preview SQL |
Displays the |
OK |
Saves your work and displays the trigger code in the PL/SQL Code Editor so that you can customize it. To commit the trigger, click the Save button in the Visual Studio .NET toolbar or select Save from the File menu. After you successfully create the trigger, Oracle Developer Tools displays its node in Server Explorer. If you have created the trigger with errors, Oracle Developer Tools displays an error dialog box, and then displays the error messages in the Output window. Click OK and correct the error in the dialog box. Afterwards, when you click the Trigger Designer's OK button to save your changes, click Yes to replace the incorrect trigger with the corrected version. Note: If a trigger produces compilation errors, it is still created, but it fails on execution. This means it effectively blocks all triggering DML statements until it is disabled, replaced by a version without compilation errors, or dropped. You can see the associated compiler error messages in the Oracle Output pane in the Output window. |