Previous Topic: SET ACCESS MODULENext Topic: SET SESSION


SET host-variable Assignment

The SET host-variable statement enables directly assigning the results of an SQL value expression to a host variable. This statement can only be used in embedded SQL.

Syntax
►►── SET ──── host-variable ───────── = ────┬─ value-expression ─┬────────────►◄
                                            └─ NULL ─────────────┘
Parameters
host-variable

Identifies a host-variable that is to receive the value of the specified value expression or null. Host-variable must be a host variable previously declared in the application program.

value-expression

Specifies the value to be assigned to the destination or receiving field of the assignment statement.

NULL

Specifies that host-variable is set to the NULL value.

Usage

The rules for assignment are provided in Comparison, Assignment, Arithmetic, and Concatenation Operations.

Example

The host-variable COMB-NAME is constructed from the values in the host-variables FIRST-NAME and LAST-NAME.

EXEC SQL
   set:COMB-NAME=trim(:FIRST-NAME) ||' '|| trim(:LAST-NAME);
END-EXEC