Use this window to set up a new database trigger or edit
the details of an existing database trigger.
The
Database Trigger Details window
contains the following areas:
Trigger
setup area
Complete this area as follows:
- Name
- Type a unique trigger name. If you are editing a trigger, you
cannot change the name.
Tip: When creating
ObjectServer objects, their names must begin with an uppercase or
lowercase letter, followed by uppercase or lowercase letters, numbers,
or underscore (_) characters, up to 40 characters in length. User,
group, and role names can be any text string up to 64 characters in
length and can include spaces. Names of ObjectServer objects are
case-sensitive.
- Group
- Select the trigger group to which you want to assign the trigger.
- Add new trigger group
- Click this button if you want to create a new trigger group to
which the trigger can then be assigned. The Trigger Group
Details window opens. Complete this window and save your
changes.
- When you return to the Database Trigger Details window,
the new trigger group is shown as the currently-selected trigger group.
Settings
tab
Complete
this tab as follows:
- On
- Select the ObjectServer database and the database table that cause
the trigger to fire.
- Priority
- Select a priority that determines the order in which the ObjectServer
fires triggers when this database modification causes more than one
trigger to fire. You can select numbers from 1 to 20, with 1 being
the highest priority.
- Pre database action/Post database action
- Click Pre database action to indicate that
the trigger action should run before the database modification that
caused the trigger to fire occurs. Click Post database
action to indicate that the trigger action should run
after the database modification that caused the trigger to fire occurs.
- For example, you can click Pre database action to
evaluate a user name before a row in the alerts.status table is deleted.
In the trigger, you can detect whether the user is allowed to delete
from the alerts.status table and, if not, prevent the database modification
from taking place. If you click Post database action,
the database modification always takes place.
- Delete/Insert/Reinsert/Update
- Use these options to specify the type of database modification
that should occur.
- Row/Statement
- Click Row to set the trigger to fire once
for each row that matches the trigger condition. Click Statement to
set the trigger to fire once regardless of the number of matched rows
in the table.
- Debug
- Select this check box to send debugging information to the ObjectServer
message log each time the trigger fires.
- Enabled
- Select this check box to activate the trigger and make it available
for use. Clear this check box to create the trigger without activating
it at the present time, or to make the trigger unavailable. A disabled
trigger does not fire when the associated database modification occurs.
When tab
Use
this tab to specify an optional WHEN clause that allows you to test
for a particular condition before the action is performed. If the
condition is not met, the action is not performed. You can use the
SQL helper buttons shown to the right of the SQL editor panel to construct
the WHEN clause.
Action
tab
Use
this tab to specify SQL commands for the trigger.
The body of a trigger
contains a set of SQL commands and programming constructs that manipulate
data in the ObjectServer. The body of a trigger is enclosed within
the keywords BEGIN and END. Each statement, except the last one, must
be separated by a semi-colon (;).
You can optionally
define (declare) local variables for use within a trigger. A local
variable is a placeholder for values used during the execution of
the trigger. Local variable declarations within a trigger must be
separated by semi-colons (;).
The trigger body has
the following syntax:
[ DECLARE variable_declaration;...[;] ]
BEGIN
trigger_statement_list
END;
You
can use the SQL helper buttons shown to the right of the SQL editor
panel to construct the SQL commands.
Saving
your trigger details
After creating or editing a trigger,
you can save or cancel the changes made by clicking the relevant button
as follows:
- OK
- Click this button to save the trigger details and close the window.
New triggers are added to the Triggers pane.
- Cancel
- Click this button to close the window without saving your changes.