DECLARE语法必须在BEGIN和END之间。语法如下-
BEGIN DECLARE yourVariableName1 dataType, DECLARE yourVariableName2 dataType, . . . . END
这是避免MySQL中DECLARE语法错误的查询-
mysql> DELIMITER // mysql> create procedure declare_Demo() -> BEGIN -> DECLARE Name varchar(100); -> SET Name: ='John'; -> SELECT Name; -> END -> // mysql> DELIMITER ;
借助CALL命令调用存储过程。语法如下-
CALL yourStoredProcedureName();
查询如下-
mysql> call declare_Demo();
以下是输出-
+------+ | Name | +------+ | John | +------+ 1 row in set (0.00 sec)