You can open triggers that are defined on tables in DB2® databases. If needed, you can
edit the trigger and then deploy and test the updated trigger.
Before you begin
The trigger must be defined on a table or a view in a DB2 database.
About this task
If a trigger is not performing properly or requires updating,
you can open the trigger in the workbench. To change the trigger,
you edit a copy of the trigger in the routine editor. You can test
your changes by deploying and activating the updated trigger. When
you deploy the trigger, the existing trigger is replaced.
Tip: From
the Properties view, you can view the trigger
and trigger properties, including the source code.
Procedure
To edit, deploy, and test a trigger:
- In the Data Source Explorer, connect
to the database and navigate to the table that contains the trigger. A Triggers folder is in each Table folder.
- Open the trigger. Right-click the trigger and
click Open in Routine Editor.
A copy of
the trigger opens in the routine editor.
- If needed, edit the trigger.
You can save
the trigger as a file on your computer. The saved file contains the
source code and property information from the database.
- Deploy the trigger from the routine editor. Click
. When deploying the
routine, enable debugging by selecting Enable debugging in
the Routine Options page of the wizard.
When
the updated trigger is deployed, it replaces the trigger in the database.
- Test the trigger. You run or debug a trigger
by activating the trigger. To activate a trigger, run a deployed routine
or create and run an SQL statement in the SQL and XQuery editor that
activates the trigger.
- To run a deployed trigger, run the routine or the SQL statement.
- To debug a deployed trigger that has the debugging option
enabled:
- Open the trigger in the routine editor and set line breakpoints
in the routine editor.
- Run the routine or the SQL statement.
When the trigger is activated,
the trigger source code is opened in the routine debugger. You can
perform debugging operations and view variables including trigger
transition variables.
Note: You can debug only one trigger at a
time. Activating and debugging two or more triggers simultaneously
is not supported.
What to do next
After you have finished testing the trigger, deploy the
trigger with debugging disabled. To disable debugging for the trigger,
clear Enable debugging when you deploy the
trigger.