LET
Use the LET statement to assign values to variables or to call a user-defined SPL routine and assign the returned value or values to SPL variables.
Syntax
Element | Description | Restrictions | Syntax |
---|---|---|---|
function | SPL function to be invoked | Must exist in the database | Identifier |
SPL_var | SPL variable to receive a value that the function, expression, or query returns | Must be defined and in scope within the statement block | Identifier; |
Usage
The LET statement can assign a value returned by an expression, function, or query to an SPL variable. At runtime, the value to be assigned is calculated first. The resulting value is cast to the data type of SPL_var, if possible, and the assignment occurs. If conversion is not possible, an error occurs, and the value of the variable remains undefined. (A LET operation that assigns a single value to a single SPL variable is called a simple assignment.)
A compound assignment assigns multiple expressions to multiple SPL variables. The data types of expressions in the expression list do not need to match the data types of the corresponding variables in the variable list, because the database server automatically converts the data types. (For a detailed discussion of casting, see the Informix® Guide to SQL: Reference.)
LET a = c + d ;
LET a,b = c,d ;
LET expire_dt = end_dt + 7 UNITS DAY;
LET name = 'Brunhilda';
LET sname = DBSERVERNAME;
LET this_day = TODAY;
LET a,b = (c,d) + (10,15); -- INVALID EXPRESSION