VALUES

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.

Invocation

This statement can only be used in the triggered action of a CREATE TRIGGER statement.

Authorization

If a row-fullselect is specified, see Queries for an explanation of the authorization required for each subselect.

Syntax

Click to skip syntax diagram

Read syntax diagramSkip visual syntax diagram>>-VALUES--+-+-expression-+---------------+--------------------><
           | '-NULL-------'               |
           |      .-,--------------.      |
           |      V                |      |
           '-(--+---+-expression-+-+-+--)-'
                |   '-NULL-------'   |
                '-row-fullselect-----'
 

Description

VALUES
Introduces a single row consisting of one of more columns.
expression
Any expression of the type described in Expressions.
NULL
Specifies the null value.
row-fullselect
A fullselect that returns a single result row. If the result of the fullselect is no rows, then null values are returned. An error is returned if there is more than one row in the result.

Notes

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).

Examples

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    


[ Top of Page | Previous Page | Next Page | Contents | Index ]