I have tried to use the export option in phpMyAdmin routines panel to copy functions from one database to another, with no success.
The export option supplies me with the following:
CREATE DEFINER=`root`@`localhost` FUNCTION `JSON_FIELD_NUM`(`col_name` TEXT CHARSET utf8, `data` TEXT CHARSET utf8) RETURNS text CHARSET utf8
NO SQL
BEGIN
RETURN
CONCAT('"',col_name,'":',
IF(ISNULL(data),0,data)
);
END
I get this error when I run that in another database:
#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 7
I tried adding DELIMITER $$ at the top and $$ after END, but still no joy.
You must set your client’s statement delimiter to a string other than
;in order that it doesn’t think the semicolon which ends theCONCAT()expression also terminates theCREATE FUNCTIONstatement.In the MySQL command line tool, you can use the
DELIMITERcommand. In phpMyAdmin, you will need to use theDelimitertext box before clickingGo.