LET
Assigns an expression to a variable or a RESULTSET.
LET is only valid within a scripting block.
See also DECLARE.
Syntax: Variable Assignment
sql
LET var_name [var_type] { DEFAULT | := } expr ;Arguments
var_name: The name of the variable.
var_type (optional): SQL data type.
DEFAULT expr or := expr (optional): Default value.
Usage Notes
If both var_type and expr are specified, expr must produce a compatible data type.
Syntax: RESULTSET Assignment
sql
LET resultset_name {DEFAULT | :=} (statement);Arguments
resultset_name: The name of the RESULTSET. The name must be unique within the current scope.
DEFAULT statement or := statement: Assigns the statement to the RESULTSET.
statement: A SQL query.
Examples
sql
DECLARE
profit INTEGER;
BEGIN
LET cost INTEGER := 700;
LET revenue INTEGER DEFAULT 770;
profit := :revenue - :cost;
select :profit AS profit;
END;txt
+-----------------+
| PROFIT |
+-----------------+
| 70 |
+-----------------+or
sql
BEGIN
LET cost INTEGER := 700;
LET revenue INTEGER DEFAULT 770;
select :revenue - :cost AS profit;
END;txt
+-----------------+
| PROFIT |
+-----------------+
| 70 |
+-----------------+