我正在尝试创建一个 SQL 函数,该函数将采用 2 个参数并转换为请求的案例格式。我的查询是
DELIMITER $$
CREATE FUNCTION Convertcase(
sentence VARCHAR(50),req_case VARCHAR(50)
)
RETURNS VARCHAR(50)
DETERMINISTIC
BEGIN
DECLARE word VARCHAR(50);
IF req_case = 'upper' THEN
SET word= UPPER(sentence);
ELSEIF req_case = 'lower' THEN
SET word= LOWER(sentence);
RETURN (word);
END$$
DELIMITER;
convertcase('test sentence','upper')
但我得到了错误
Query : CREATE FUNCTION Convertcase( sentence varchar(50),req_case varchar(50) ) RETURNS VARCHAR(50) DETERMINISTIC BEGIN DECL...
Error Code : 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 13