我在安装组件时尝试在install.sql中创建一个mysql函数。该功能如下所示:
DROP FUNCTION IF EXISTS `dm`;
CREATE FUNCTION `dm`(st VARCHAR(55)) RETURNS varchar(128) CHARSET utf8
NO SQL
BEGIN
DECLARE length, first, last, pos, prevpos, is_slavo_germanic SMALLINT;
DECLARE pri, sec VARCHAR(45) DEFAULT '';
DECLARE ch CHAR(1);
...
这很长,所以你可以在这里找到完整版本:
https://github.com/AtomBoy/double-metaphone/blob/master/metaphone.sql
我发现了这个问题:
Create a mysql function while installing a component
但我已经删除了分隔符,但在安装组件时仍会出现此错误:
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 4 SQL=CREATE FUNCTION `dm`(st VARCHAR(55)) RETURNS varchar(128) CHARSET utf8 NO SQL BEGIN DECLARE length, first, last, pos, prevpos, is_slavo_germanic SMALLINT;
SQL =
CREATE FUNCTION `dm`(st VARCHAR(55)) RETURNS varchar(128) CHARSET utf8
NO SQL
BEGIN
DECLARE length, first, last, pos, prevpos, is_slavo_germanic SMALLINT;
数据库错误代码是1064。