MySQL :: MySQL 8.4 Reference Manual :: 15.6.3 DECLARE Statement (original) (raw)
15.6.3 DECLARE Statement
The DECLARE statement is used to define various items local to a program:
- Local variables. SeeSection 15.6.4, “Variables in Stored Programs”.
- Conditions and handlers. SeeSection 15.6.7, “Condition Handling”.
- Cursors. See Section 15.6.6, “Cursors”.
DECLARE is permitted only inside aBEGIN ... END compound statement and must be at its start, before any other statements.
Declarations must follow a certain order. Cursor declarations must appear before handler declarations. Variable and condition declarations must appear before cursor or handler declarations.