我的生产服务器上有一个运行 MySQL v5.5.8 的函数,可以正常执行。
当我尝试在运行 MySQL v5.5.9 的测试服务器上创建相同的功能时,创建失败并出现错误 1064。有人可以解释为什么在一台服务器上可以,而在另一台服务器上不行吗?为什么 MySQL 会返回如此模糊和无用的消息,我永远不会知道!!!
创建是:
DELIMITER $$
CREATE FUNCTION `CheckProjType` (type INT, cost BIGINT )
RETURNS VARCHAR(50)
CHARSET latin1
NO SQL
BEGIN
DECLARE rtn VARCHAR(50);
IF type = 5 THEN SET rtn = 'New Maint';
ELSE
IF type = 4 THEN SET rtn = 'Ongoing Maintenance';
ELSE
IF type = 3 THEN SET rtn = 'New Development';
else
IF cost > 1000000000 THEN SET rtn = 'New Expansion';
else
IF cost > 250000000 THEN SET rtn = 'Major Improvement';
ELSE
IF cost > 25000000 THEN SET rtn = 'Major Development';
ELSE
SET rtn = 'Small Improvement';
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
RETURN rtn;
END $$
DELIMITER ;
这是错误:
ERROR 1064: 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 '' at line 6
SQL Statement:
CREATE FUNCTION `CheckProjType` (type INT, cost BIGINT )
RETURNS VARCHAR(50)
CHARSET latin1
NO SQL
BEGIN
DECLARE rtn VARCHAR(50)