Variable
A variable has a value.
Naming restriction: Parsing - Statements
Declare Variable
variable_declaration
: DECLARE variable_assignment [, variable_assignment...];
| VAR variable_assignment [, variable_assignment...];
variable_assignment
: @varname
| @varname := initial_value
- initial_value
- value
VAR is an alias of DECLARE.
If the initial_value is not specified, then a null is set to the variable.
Substitute
A variable subsitution expression returns the substituted value.
@varname := value
- value
- value
The variable substitution expression can be used in query statements such as update queries, select clauses in select queries. If this expression exists in the other than select clauses of a select query, then no error occurs, but the order of the operation is not guranteed.
SELECT INTO Statement
SELECT INTO statement substitutes the result into the variables. The result set of the query must be at most 1 record.
select_into_statement
: [with_clause]
select_clause
INTO variable [, variable ...]
[from_clause]
[where_clause]
[group_by_clause]
[having_clause]
[order_by_clause]
[limit_clause]
[offset_clause]
[FOR UPDATE]
- with_clause
- With Clause
- select_clause
- Select Clause
- variable
- Variable
- from_clause
- From Clause
- where_clause
- Where Clause
- group_by_clause
- Group By Clause
- having_clause
- Having Clause
- order_by_clause
- Order By Clause
- limit_clause
- Limit Clause
- offset_clause
- Offset Clause
Dispose Variable
DISPOSE @varname;