A database trigger is a stored subprogram associated with a database table, view, or event. The trigger can be called once, for example when an event occurs, or many times, for example for each row affected by an INSERT, UPDATE, or DELETE statement.
Topics:
See Also: Oracle Database Concepts and SQL*Plus User's Guide and Reference for information about triggers |
To create a trigger:
Navigate to Object Browser:
Click the SQL Workshop icon on the Workspace home page.
Click Object Browser.
Object Browser appears.
Click Create.
From the list of object types, select Trigger.
Select a table name and click Next.
Select the appropriate trigger attributes, enter the trigger body, and click Next.
A confirmation page appears. To view the SQL used to create the trigger, click SQL.
Click Finish.
To browse a trigger in Object Browser:
Navigate to Object Browser:
Click the SQL Workshop icon on the Workspace home page.
Click Object Browser.
Object Browser appears.
From the Object list, select Triggers.
From the Object Selection pane, select a trigger.
The Details view appears.
Click the tabs at the top of the page to view different reports about the trigger. Table 18-10 describes all available views.
Table 18-10 Available Views for Triggers
View | Description |
---|---|
Object Details |
(Default) Lists of the details about the current trigger. Actions you can perform include:
See Also: "Editing a Trigger", "Compiling a Trigger", "Downloading a Trigger", and "Dropping a Trigger" |
Errors |
Displays errors related to the current trigger. |
SQL |
Displays the SQL necessary to re-create the trigger. |
When you edit a trigger you can edit the code manually, perform a search and replace, and compile the trigger.
To edit a trigger manually:
Navigate to Object Browser:
Click the SQL Workshop icon on the Workspace home page.
Click Object Browser.
Object Browser appears.
From the Object list, select Triggers.
From the Object Selection pane, select a trigger.
Select the Code tab and then click Edit to activate manual edit mode.
Click Find to perform a basic search and replace.
Note: You can expand the Edit pane by clicking the Full Screen icon in the upper right of the pane, beneath the Create button. |
If you edit and make changes to a function, you need to compile in order to save your changes. There is no save function because this is just a view of the object within the database.
Click Compile to compile the current trigger. Compiling re-creates the object in the database. If the compile fails, an error message display above the code.