[英]mysql function error in syntax
我正在嘗試編寫一個函數(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
所以我做到了。 https://stackoverflow.com/a/26015334/8821276
SET GLOBAL log_bin_trust_function_creators = 1;
log_bin_trust_function_creators = 1
現在就可以了,謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.