You can specify whether a trigger action is to be performed by defining a condition when defining the trigger.
The following example shows how to use a correlation name in an expression within a condition. If the event type is INSERT, UPDATE or DELETE, the expression in the condition can reference the correlation names obj, new or old to access a specific column. This example prefixes obj to the column name in the trigger condition to show that the example trigger tests the condition based on the current value of the record column.
CREATE TRIGGER example
........
IF obj.record * 1.20 < 500
.......
The following example shows how to use the SELECT statement in an expression within a condition. The trigger in this example uses the SELECT statement that contains an aggregate function COUNT( * ) to compare the value with a constant. The SELECT statement must be enclosed in parentheses and must be placed at the end of the expression.
CREATE TRIGGER example
......
IF 1000 > (SELECT COUNT( * ) FROM participant)
......
The expression given in the trigger condition may cause side effects on the database if a method is called while the condition is performed. A trigger condition must be constructed to avoid unexpected side effects in the database.