DELIMITER $$
CREATE FUNCTION ecmsbackoffice.getSequence($delimeter VARCHAR(20)) RETURNS VARCHAR(20)
BEGIN
DECLARE result VARCHAR(20);
SET result = 0;
IF (delimeter='B') THEN UPDATE id_generator SET seq_currval=(seq_currval+1) WHERE seq_name='B';
ELSE IF (delimeter='D') THEN UPDATE id_generator SET seq_currval=(seq_currval+1) WHERE seq_name='D';
ELSE IF (delimeter='C') THEN UPDATE id_generator SET seq_currval=(seq_currval+1) WHERE seq_name='C';
END IF
SELECT seq_currval INTO result
FROM id_generator
WHERE seq_name = delimeter;
RETURN result;
END $$
DELIMITER ;
我正在尝试创建一个 MySQL 函数,但出现以下错误:
错误代码:1064
您的 SQL 语法有错误;检查与您的 MySQL >server 版本相对应的手册,以获取在 'SELECT seq_currval INTO result
from id_generator
WHERE seq_name = demeter;附近使用的正确语法
第 9 行的 R'
问题是什么?