LET (Snowflake Scripting)¶
Assigns an expression to a Snowflake Scripting variable, cursor, or RESULTSET.
For more information on variables, cursors, and RESULTSETs, see:
Note
This Snowflake Scripting construct is valid only within a Snowflake Scripting block.
- See also:
Syntax¶
The syntax for each type of assignment is described below in more detail.
Variable assignment syntax¶
Use the following syntax to assign an expression to a variable.
Where:
variable_nameThe name of the variable. The name must follow the naming rules for object identifiers.
typeDEFAULT expressionor .:= expressionAssigns the value of
expressionto the variable.If both
typeandexpressionare specified, the expression must evaluate to a data type that matches.
For example, the following LET statements declare three variables of type NUMBER,
with precision set to 38 and scale set to 2. All three variables have a default value, using either DEFAULT
or := to specify it.
For more examples, see:
Cursor assignment syntax¶
Use one of the following syntaxes to assign an expression to a cursor.
Where:
cursor_nameThe name to give the cursor. This can be any valid Snowflake identifier that is not already in use in this block. The identifier is used by other cursor-related commands, such as FETCH (Snowflake Scripting).
queryThe query that defines the result set that the cursor iterates over.
This can be almost any valid SELECT statement.
resultset_nameThe name of the RESULTSET for the cursor to operate on.
For example, the following LET statement declares cursor c1 for a query:
For more examples, see Working with cursors.
RESULTSET assignment syntax¶
Use the following syntax to assign an expression to a RESULTSET.
Where:
resultset_nameThe name to give the RESULTSET.
The name should be unique within the current scope.
The name must follow the naming rules for Object identifiers.
DEFAULT queryor .:= queryAssigns the value of
queryto the RESULTSET.
For example, the following LET statement declares RESULTSET res for a query:
For more examples, see Working with RESULTSETs.