Open yiyebaofu2 opened 8 years ago
两个办法:
对创建函数处做如下改动,即可顺利导入:
delimiter //
CREATE FUNCTION FUN_SEQ
(SEQ VARCHAR(50)) RETURNS BIGINT(20)
BEGIN
UPDATE SEQ_TABLE
SET CURRENT_VALUE = CURRENT_VALUE + INCREMENT
WHERE SEQ_NAME=SEQ;
RETURN FUN_SEQ_CURRENT_VALUE(SEQ);
END //
CREATE FUNCTION FUN_SEQ_CURRENT_VALUE
(SEQ VARCHAR(50)) RETURNS BIGINT(20)
BEGIN
DECLARE VALUE INTEGER;
SET VALUE=0;
SELECT CURRENT_VALUE INTO VALUE
FROM SEQ_TABLE
WHERE SEQ_NAME=SEQ;
RETURN VALUE;
END //
CREATE FUNCTION FUN_SEQ_SET_VALUE
(SEQ VARCHAR(50), VALUE INTEGER) RETURNS BIGINT(20)
BEGIN
UPDATE SEQ_TABLE
SET CURRENT_VALUE=VALUE
WHERE SEQ_NAME=SEQ;
RETURN FUN_SEQ_CURRENT_VALUE(SEQ);
END //
CREATE FUNCTION FUN_NOW() RETURNS DATETIME BEGIN RETURN now(); END //
-- 时间函数
CREATE FUNCTION FUN_DATE_ADD
(STR_DATE VARCHAR(10), STR_INTERVAL INTEGER) RETURNS DATE
BEGIN
RETURN date_add(STR_DATE, INTERVAL STR_INTERVAL DAY);
END //
delimiter ;
执行 database.sql 的时候创建function错误 mysql版本5.7
ERROR 1064 (42000): 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 5 ERROR 1064 (42000): 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 'RETURN FUN_SEQ_CURRENT_VALUE(SEQ)' at line 1 ERROR 1064 (42000): 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 'END' at line 1 ERROR 1064 (42000): 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 3 ERROR 1193 (HY000): Unknown system variable 'VALUE' ERROR 1327 (42000): Undeclared variable: VALUE ERROR 1064 (42000): 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 'RETURN VALUE' at line 1 ERROR 1064 (42000): 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 'END' at line 1 ERROR 1064 (42000): 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 5 ERROR 1064 (42000): 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 'RETURN FUN_SEQ_CURRENT_VALUE(SEQ)' at line 1 ERROR 1064 (42000): 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 'END' at line 1 ERROR 1064 (42000): 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 ERROR 1064 (42000): 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 'END' at line 1 ERROR 1064 (42000): 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 3 ERROR 1064 (42000): 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 'END' at line 1