我正在尝试编写一个函数(MariaDB 10.2.9)。
CREATE FUNCTION tesst (host VARCHAR(30)) RETURNS INT(4)
BEGIN
DECLARE hwid INT(4);
SELECT `id` INTO hwid FROM `hardware` WHERE `hostname` = host;
RETURN COALESCE(hwid, 'HWID not found');
END
现在我收到以下错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 3
我不知道错误是什么。
编辑: 它适用于
delimiter //
CREATE FUNCTION tesst (host VARCHAR(30)) RETURNS int(4)
BEGIN
DECLARE hwid INT(4);
SELECT `id` INTO hwid FROM `hardware` WHERE `hostname` = host;
RETURN COALESCE(hwid, 'HWID not found');
END //
delimiter ;
并设置:
SET GLOBAL log_bin_trust_function_creators = 1;
log_bin_trust_function_creators = 1
答案 0 :(得分:0)
所以我做到了。 https://stackoverflow.com/a/26015334/8821276
SET GLOBAL log_bin_trust_function_creators = 1;
log_bin_trust_function_creators = 1
现在有效,谢谢!