The DECLARE
statement is used to define various items local to a program:DECLARE
语句用于定义程序的各种局部项:
Local variables. 局部变量。See Section 13.6.4, “Variables in Stored Programs”.请参阅第13.6.4节,“存储程序中的变量”。
Conditions and handlers. 条件和处理程序。See Section 13.6.7, “Condition Handling”.请参阅第13.6.7节,“条件处理”。
Cursors. 指针。See Section 13.6.6, “Cursors”.请参阅第13.6.6节,“指针”。
只允许在DECLARE
is permitted only inside a BEGIN ... END
compound statement and must be at its start, before any other statements.BEGIN ... END
复合语句中使用DECLARE
,并且必须在其开始处,在任何其他语句之前。
Declarations must follow a certain order. 声明必须遵循一定的顺序。Cursor declarations must appear before handler declarations. 指针声明必须出现在处理程序声明之前。Variable and condition declarations must appear before cursor or handler declarations.变量和条件声明必须出现在游标或处理程序声明之前。