Variables in SQL procedures
For data that you use only within an SQL procedure, you can declare SQL variables and store the values in the variables. SQL variables are similar to host variables in external stored procedures. SQL variables can be defined with the same data types and lengths as SQL procedure parameters.
An SQL variable declaration has the following form:
DECLARE SQL-variable-name data-type;
An SQL variable is defined in a compound statement. SQL variables can be referenced anywhere in the compound statement in which they are declared, including any SQL statement that is directly or indirectly nested within that compound statement. For more information, see References to SQL parameters and variables in SQL PL.
You can perform any operations on SQL variables that you can perform on host variables in SQL statements.