MySQL在创建存储过程的时候,语法正确却提示You have an error in your SQL syntax
我在使用MySQL工具编写MySQL存储过程的时候,明明语法正确,但是却一直提示You have an error in your SQL syntax。
比如下面一段代码
CREATE PROCEDURE demo_pro()
BEGIN
DECLARE doned BOOLEAN;
DECLARE addr varchar(20);
DECLARE demo_cur CURSOR FOR SELECT detail from address;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET doned = True;
SET doned = False;
OPEN demo_cur;
demo_cur:LOOP
FETCH demo_cur into addr;
IF doned THEN
LEAVE demo_cur;
ELSE
insert into demo(demo_value) values(addr);
END IF;
END LOOP;
CLOSE demo_cur;
END;
找了半天才找到解决方案,原来不是语法的错误,是MYSQL语法解析器的原因。MYSQL 解析器解析遇到“;”分号,就结束本次执行,所以就造成了很多语法错误。解决方案是:
DELIMITER | #结束符号,可以根据自己的需求,改成 $也可以
CREATE PROCEDURE demo_pro()
BEGIN
DECLARE doned BOOLEAN;
DECLARE addr varchar(20);
DECLARE demo_cur CURSOR FOR SELECT detail from address;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET doned = True;
SET doned = False;
OPEN demo_cur;
demo_cur:LOOP
FETCH demo_cur into addr;
IF doned THEN
LEAVE demo_cur;
ELSE
insert into demo(demo_value) values(addr);
END IF;
END LOOP;
CLOSE demo_cur;
END;|
DELIMITER ;
MySQL在创建存储过程的时候,语法正确却提示You have an error in your SQL syntax的更多相关文章
- 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 '
mysql中如果字段使用了关键字,在插入和更新时会提示 You have an error in your SQL syntax; check the manual that corresponds ...
- mysql 中创建存储过程
mysql中创建存储过程和存储函数虽相对其他的sql语言相对复杂,但却功能强大,存储过程和存储函数更像是一种sql语句中特定功能的一种封装,这种封装可以大大简化外围调用语句的复杂程度. 首先以表emp ...
- C# Mysql 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 ????
有几年没用过MySql数据了,今天在使用C#访问MySql数据库时出现了一个小插曲. 错误提示: You have an error in your SQL syntax; check the man ...
- MySQLSyntaxErrorException: 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 ...
下面是我update数据库时打印出来的异常: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSynt ...
- 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 'group t1,customer t2
### SQL: select t1.gid,t1.gname,t1.gvalue,t1.gtype, t1.gaddress,t1.gmembers, t1.gcode,t1.gphone, t2. ...
- MySql 建表出现的问题:[ERR] 1064 - You have an error in your SQL syntax; check the manual.......
使用 MySql 建表出现的问题 在使用 Navicat Premium 运行 sql 语句进行建表时,MySQL 报错如下: 建表语句: DROP DATABASE IF EXISTS javawe ...
- 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 'varchar(255), sort integer not null
you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version ...
- [Err] 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 ''<h1 style="text-align: center;">php
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL s ...
- ERROR: 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 'type=InnoDB' at line 7
问题: 使用hibernate4.1.1,数据库使用mysql5.1.30,使用hibernate自动生成数据库表时,hibernate方言使用org.hibernate.dialect.MySQLI ...
随机推荐
- Python数据类型转换
Python数据类型之间的转换 函数 描述 int(x [,base]) 将x转换为一个整数 long(x [,base] ) 将x转换为一个长整数 float(x) 将x转换到一个浮点数 compl ...
- HDU 4389——X mod f(x)(数位DP)
X mod f(x) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Probl ...
- 服务器后端开发系列——《实战FastDFS分布式文件系统》[转]
1.FastDFS的配置.部署与API使用解读(1)Get Started with FastDFS 内容:讲解FastDFS的背景.基本原理,并讲述基本的配置.部署和测试的内容. 2.FastDFS ...
- android82 文件下载框架xUtils
package com.itheima.xutils; import java.io.File; import com.lidroid.xutils.HttpUtils; import com.lid ...
- maven 学习1 -安装maven 并执行编译命令
一.maven 下载与安装(安装好jdk的前提下) 1.下载地址:http://maven.apache.org/download.cgi (选择最新的zip版本),下载完毕后解压 2.安装:系统p ...
- ClassLoader(摘录)
Java虚拟机类加载过程是把Class类文件加载到内存,并对Class文件中的数据进行校验.转换解析和初始化,最终形成可以被虚拟机直接使用的java类型的过程. 在加载阶段,java虚拟机需要完成以下 ...
- yo bootstrap mui 使用对比
昨天晚上 又被问及职业发展方向,提及我的老本行css,切了几年的页面,近两年投入进css的时间屈指可数,被问及之前公司用的yo框架 对比业界内其他css 框架的优势. 1. yo模块化,碎片化 可自 ...
- boost.log要点笔记
span.kw { color: #007020; font-weight: bold; } code > span.dt { color: #902000; } code > span. ...
- update inner join
string sql = @"update a set a.M_ParentID=b.M_ParentID, a.M_Name=b.M_Name, a.M_Seq=b.M_Seq from ...
- python matplotlib.plot画图显示中文乱码的问题
在matplotlib.plot生成的统计图表中,中文总是无法正常显示.在网上也找了些资料,说是在程序中指定字体文件,不过那样的话需要对plot进行很多设置,而且都是说的设置坐标轴标题为中文,有时候图 ...