No matter how simple you define your function, its creation will fail when using HeidiSQL interface.
CREATE FUNCTION `fn_my_function`(
`parameter_a` INT
)
RETURNS INT
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
return 0;
END
After reviewing your code, you can’t find any syntax error. You try to fix it by removing the COMMENT ” line, but nothing seems to work.
The solution is quite simple:
- Tell the SQL engine a new DELIMITER:
- DELIMITER //
- After the END; line, add another one to restore the DELIMITER to ;
- DELIMITER ;
- That’s all
DELIMITER //
CREATE FUNCTION `fn_my_function`(
`parameter_a` INT
)
RETURNS INT
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
return 0;
END
DELIMITER ;
Please note that there is a space separator between DELIMITER and ;
