2 Day Developer > Using Triggers > Managing Triggers in the Da... > Creating a Trigger With the...
Creating a Trigger With the SQL Commands Page |
Previous |
Next |
With the SQL Commands page, you can create and update triggers.
To create a trigger with the SQL Commands page:
Log in to the Database Home Page. See "Logging in to the Database Home Page". To run the examples in this guide, you should log in as user HR
with your password for the HR
account.
On the home page, click the SQL icon to display the SQL page.
Click the SQL Commands icon to display the SQL Command page.
On the SQL Commands page, first enter the SQL statements to create any objects that are needed in the trigger body. For example, the emp_audit
table needs to be created before creating the audit_sal
trigger in Example: Creating a Database Trigger WIth the AFTER Option. If a database object is referred to in the trigger code, then that object must exist for the trigger to be valid.
Click the Run button to execute the SQL statements to create any supporting objects for the trigger. If the statements run successfully, delete the statements from the SQL Commands page. Otherwise, update the statements so they run successfully.
On the SQL Commands page, enter the PL/SQL code to create the trigger after any objects that are needed by the trigger are created. For an example of code to create a trigger, see Example: Creating a Database Trigger WIth the AFTER Option.
Click the Run button to execute the PL/SQL code to create the trigger. Correct the code if it does not execute successfully.
If you want to save the PL/SQL code for future use, click the Save button.
In the Name field, enter a name for the saved PL/SQL code. You can also enter an optional description. Click the Save button to complete the action.
To access the saved PL/SQL code, click the Saved SQL tab and select the name of the saved PL/SQL code that you want to access.
See Also: Oracle Database Express Edition Application Express User's Guide for detailed information about using SQL Commands |