13.6.4 Variables in Stored Programs存储程序中的变量

13.6.4.1 Local Variable DECLARE Statement局部变量DECLARE语句
13.6.4.2 Local Variable Scope and Resolution局部变量的作用域和分辨率

System variables and user-defined variables can be used in stored programs, just as they can be used outside stored-program context. 系统变量和用户定义变量可以在存储程序中使用,就像它们可以在存储程序上下文之外使用一样。In addition, stored programs can use DECLARE to define local variables, and stored routines (procedures and functions) can be declared to take parameters that communicate values between the routine and its caller.此外,存储程序可以使用DECLARE来定义局部变量,存储例程(过程和函数)可以声明为获取在例程及其调用方之间传递值的参数。

For information about the scope of local variables and how MySQL resolves ambiguous names, see Section 13.6.4.2, “Local Variable Scope and Resolution”.有关局部变量的作用域以及MySQL如何解析不明确名称的信息,请参阅第13.6.4.2节,“局部变量作用域和解析”

It is not permitted to assign the value DEFAULT to stored procedure or function parameters or stored program local variables (for example with a SET var_name = DEFAULT statement). 不允许将值DEFAULT赋给存储过程或函数参数或存储程序局部变量(例如,使用SET var_name = DEFAULT语句)。In MySQL 8.0, this results in a syntax error.在MySQL 8.0中,这会导致语法错误。

13.6.4.1 Local Variable DECLARE Statement
13.6.4.2 Local Variable Scope and Resolution