The DECLARE statement is used to create local variables, conditions, handlers, and cursors within the procedure.
DECLARE must be the first statements immediately within a BEGIN block.
A common declaration is the local variable, which is done with a variable name and type:
DECLARE <name> <data type> [DEFAULT];
Variable declarations can use any valid data type for MySQL, and may include an optional default value.
The default value is optional when declaring a variable.
The following is an example of declaring an integer named order_tax with an initial value of 0:
DECLARE myVariable DECIMAL(10,2) DEFAULT 0;
11.33.Declare |
| 11.33.1. | The DECLARE Statement |