Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql 执行错误 #12

Open
yiyebaofu2 opened this issue Sep 6, 2016 · 2 comments
Open

sql 执行错误 #12

yiyebaofu2 opened this issue Sep 6, 2016 · 2 comments

Comments

@yiyebaofu2
Copy link

执行 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

@leslie52
Copy link
Contributor

leslie52 commented Sep 6, 2016

两个办法:

  1. 用Navicat for MySQL这个工具 导入脚本
  2. 脚本中 创建函数处加转义符处理

@zhaodp
Copy link

zhaodp commented Apr 17, 2017

对创建函数处做如下改动,即可顺利导入:

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 ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants