VALUES
The VALUES statement provides a method for invoking a user-defined function from a trigger. Transition variables and transition tables can be passed to the user-defined function.
Invocation
This statement can only be used in the triggered action of a trigger.
Authorization
Authorization is required for any expressions that are used in the statement. For more information, see Expressions.
Syntax
>>-VALUES--+-expression-------------+-------------------------->< | .-,--------------. | | V | | '-(-----expression---+-)-'
Description
- VALUES
- Specifies
one or more expressions. If more than one expression is specified,
the expressions must be enclosed within parentheses.
- expression
- Any expression of the type described in Expressions. The expression must not contain a host variable.
If a user-defined function is specified as part of an expression, the user-defined function is invoked. If a negative SQLCODE is returned when the function is invoked, DB2® stops executing the trigger and rolls back any triggered actions that were performed.
Example
Example: Create
an after trigger EMPISRT1 that invokes user-defined function NEWEMP
when the trigger is activated. An insert operation on table EMP activates
the trigger. Pass transition variables for the new employee number,
last name, and first name to the user-defined function.
CREATE TRIGGER EMPISRT1
AFTER INSERT ON EMP
REFERENCING NEW AS N
FOR EACH ROW
MODE DB2SQL
BEGIN ATOMIC
VALUES(NEWEMP(N.EMPNO, N.LASTNAME, N.FIRSTNAME));
END