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 ...
随机推荐
- ABAP ALV表头的实现
ABAP实现ALV表头的DEMO: 效果: 源代码: *&------------------------------------------------------------------- ...
- Windows下安装Eric5时出现的“Sorry, please install QtHelp.”问题解决办法
解决Windows下安装Eric5时出现的“Sorry, please install QtHelp.”问题 PyQt4在Windows中使用了DirectX作为加速,不过,PyQt4没有使用最新 ...
- Android APK反编译具体解释(附图)
这段时间在学Android应用开发,在想既然是用Java开发的应该非常好反编译从而得到源码吧,google了一下,确实非常easy,下面是我的实践过程. 在此郑重声明,贴出来的目的不是为了去破解人家的 ...
- 绿色tftpserver:tftpd32的配置
嵌入式开发中少不了用到TFTP服务,它的功能主要是用来给目标板传输文件. tftpd32.exe是如今最经常使用的TFTPserver,今天就来介绍它的配置方法. 1.从这里 下载新版本号tftpd3 ...
- 自定义toast功能
http://download.csdn.net/detail/caryt/8105031
- myeclipse开发代码颜色搭配保护视力
废话不多说,这个东西主要是为了保护视力的,另外我也挺喜欢上边的颜色搭配的,今天特拿出来分享.直接上图
- mybatis11 sqlMapConfig.xml文件说明
1sqlMapConfig.xml SqlMapConfig.xml中配置的内容和顺序如下: properties(属性) settings(全局配置参数) typeAliases(类型别名) typ ...
- PureMVC(JS版)源码解析(七):Mediator类
之前的博文中,我们分析了SimpleCommand类和MacroCommand类,这两个类用作"业务逻辑(business logic)"处理,今天,我们讲一些和UI界面相关联的M ...
- jquery mobile入门资料
由于项目中用到了,就去看了一下视频,然后进一步的找找资源,最后自己再总结一遍!(就是动手操作一遍,不论你感觉多简单,只有动手之后,你才有可能有收获) 当然如果你喜欢看文档可以到官网仔细研究,不过喜欢快 ...
- not exists 跟not in 纪念一下