Variables
A variable in an SQL statement specifies a value that can be changed when the SQL statement is executed. There are several types of variables used in SQL statements.
- Global variables
- Global variables are either built-in global variables or user-defined global variables. For more information about global variables, see Global variables.
- Session variables
- Session variables are either built-in session variables or user-defined session variables. For more information about session variables, see Session variables.
- Host variables
- Host variables are defined by statements of a host language. For more information about how to refer to host variables, see Host variables.
- Transition variables
- Transition variables are defined in a trigger and refer to either the old or new values of columns of the subject table or view of a trigger. For more information about how to refer to transition variables, see CREATE TRIGGER statement (basic trigger).
- SQL variables
- SQL variables are defined by an SQL compound statement in an SQL function or SQL procedure. For more information about SQL variables, see References to SQL parameters and variables in SQL PL.
- SQL parameters
- SQL parameters are defined in an CREATE FUNCTION (SQL Scalar), CREATE FUNCTION (SQL table), or CREATE PROCEDURE (SQL) statement. For more information about SQL parameters, see References to SQL parameters and variables in SQL PL.
- Parameter markers
- Parameter markers are specified in an SQL statement that is dynamically prepared, instead of variables, other than global variables. For more information about parameter markers, see Parameter markers in the PREPARE statement.
Unless otherwise noted, the term variable in syntax diagrams is used to describe where a global variable, host variable, transition variable, SQL variable, SQL parameter, or parameter marker can be used.