ERROR 1064 (42000):ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE i INT DEFAULT 0' at line 1
创建存储过程时,报错了。
DROP PROCEDURE IF EXISTS GameServerMergePro;
CREATE PROCEDURE `GameServerMergePro` (
IN dbSchema VARCHAR(50) character set utf8,
IN sName VARCHAR(50) character set utf8,
OUT error_code INT
)
begin
DECLARE ddddi INT DEFAULT 0;
end;
琢磨了半天,原来Mysql解释器一遇到;号时就结束,回车以后就执行了。但是现在并不希望Mysql这么做,因为存储过程中可能 包含很多分号的语句,所以怎么办了,很简单Mysql给我们提供了delimiter关键字,delimiter作用就是把;分号替换成指定的符号,比如//或$$。当再出现//或$$时,Mysql解释器才会执行命令。
脚本改成下面之后,执行就不会报错了。
DELIMITER //
DROP PROCEDURE IF EXISTS GameServerMergePro;
CREATE PROCEDURE `GameServerMergePro` (
IN dbSchema VARCHAR(50) character set utf8,
IN sName VARCHAR(50) character set utf8,
OUT error_code INT
)
begin
DECLARE ddddi INT DEFAULT 0;
end;
//
DELIMITER ;