我正在使用MySQL v5.1.36,我正在尝试使用此代码创建存储函数.
DELIMITER //
CREATE FUNCTION `modx`.getSTID (x VARCHAR(255)) RETURNS INT DETERMINISTIC
BEGIN
DECLARE y INT;
SELECT id INTO y
FROM `modx`.coverage_state
WHERE `coverage_state`.name = x;
RETURN y;
END//
MysqL> DELIMITER //
MysqL> CREATE FUNCTION `modx`.getSTID (x VARCHAR(255)) RETURNS INT DETERMINISTIC
-> BEGIN
-> DECLARE y INT;
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 '' at
line 3
MysqL> SELECT id INTO y
-> FROM `modx`.coverage_state
-> WHERE `coverage_state`.name = x;
ERROR 1327 (42000): Undeclared variable: y
MysqL> RETURN y;
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 'RETUR
N y' at line 1
MysqL> END//
从我在网上找到的我的语法是正确的.我究竟做错了什么?
最佳答案
原文链接:https://www.f2er.com/mysql/432853.html