The VALUES statement provides a method for invoking a user-defined function from a trigger. Transition variables can be passed to the user-defined function.
This statement can only be used in the triggered action of a CREATE TRIGGER statement.
If a row-fullselect is specified, see Queries for an explanation of the authorization required for each subselect.
>>-VALUES--+-+-expression-+---------------+-------------------->< | '-NULL-------' | | .-,--------------. | | V | | '-(--+---+-expression-+-+-+--)-' | '-NULL-------' | '-row-fullselect-----'
Effects of the statement: The statement is evaluated, but the resulting values are discarded and are not assigned to any output variables. If an error is returned, the database manager stops executing the trigger and rolls back any triggered actions that were performed as well as the statement that caused the triggered action (unless the trigger is running under isolation level *NONE).
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 EMPLOYEE REFERENCING NEW AS N FOR EACH ROW MODE DB2SQL BEGIN ATOMIC VALUES( NEWEMP(N.EMPNO, N.LASTNAME, N.FIRSTNAME)); END