DECLAREvar_name
[,var_name
] ...type
[DEFAULTvalue
]
This statement declares local variables within stored programs. 此语句声明存储程序中的局部变量。To provide a default value for a variable, include a 要为变量提供默认值,请包含DEFAULT
clause. DEFAULT
子句。The value can be specified as an expression; it need not be a constant. 值可以指定为表达式;它不必是常数。If the 如果缺少DEFAULT
clause is missing, the initial value is NULL
.DEFAULT
子句,则初始值为NULL
。
Local variables are treated like stored routine parameters with respect to data type and overflow checking. 对于数据类型和溢出检查,局部变量被视为存储的例程参数。See Section 13.1.17, “CREATE PROCEDURE and CREATE FUNCTION Statements”.请参阅第13.1.17节,“创建过程和创建函数语句”。
Variable declarations must appear before cursor or handler declarations.变量声明必须出现在游标或处理程序声明之前。
Local variable names are not case-sensitive. 局部变量名不区分大小写。Permissible characters and quoting rules are the same as for other identifiers, as described in Section 9.2, “Schema Object Names”.允许的字符和引用规则与其他标识符相同,如第9.2节,“模式对象名称”所述。
The scope of a local variable is the 局部变量的作用域是在其中声明的BEGIN ... END
block within which it is declared. BEGIN ... END
块。The variable can be referred to in blocks nested within the declaring block, except those blocks that declare a variable with the same name.可以在嵌套在声明块中的块中引用变量,但声明具有相同名称的变量的块除外。
For examples of variable declarations, see Section 13.6.4.2, “Local Variable Scope and Resolution”.有关变量声明的示例,请参阅第13.6.4.2节,“局部变量范围和解析”。