声明变量

You are viewing an old version of this article. View the current version here.

语法结构:

DECLARE var_name [, var_name] ... type [DEFAULT value]

解释说明:

该语句用来在存储过程中声明局部变量。可以用DEFAULT 关键字指定默认值,这个默认值也不一定是常量。如果不指定默认值,那么初始值为null

局部变量可以看成是一个带数据类型的参数。更多信息参考存储过程

局部变量必须声明在CONDITIONs, CURSORs and HANDLERs之前。

局部变量对大小写不敏感。

局部变量使用范围限制在 BEGIN ... END之内。如果代码块中嵌套代码块,那嵌套中的代码可以引用上一级的变量。

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.