VALUES statement

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 for VALUES

This statement can only be used in the triggered action of a basic trigger.

VALUES followed by a sequence-reference is a values-clause, which is a form of fullselect. For information about invocation of the values-clause, see fullselect.

Authorization for VALUES

Authorization is required for any expressions that are used in the statement. For more information, see Expressions.

Syntax for VALUES

Read syntax diagramSkip visual syntax diagramVALUESexpression(,expression)

Description for VALUES

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.
The expressions are evaluated, but the resulting values are discarded and are not assigned to any output variables.

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 for VALUES

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