我在运行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)