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 ...
随机推荐
- hadoop ssh无密码登陆
VM DHCP蛋疼了,这次整个static... scp
- [Redux] Using withRouter() to Inject the Params into Connected Components
We will learn how to use withRouter() to inject params provided by React Router into connected compo ...
- HDU 1124 Factorial (数论)
http://acm.hdu.edu.cn/showproblem.php? pid=1124 題目好長好長,好可怕,看完腎都萎了,以後肯定活不長.我可不能死在這種小事上,小灰灰我勵志死在少女的超短裙 ...
- 查看源码Vim+Cscope
http://blog.csdn.net/huiguixian/article/details/7044869
- LabVIEW设计模式系列——case结构模拟事件结构
标准:1.所有按钮的机械动作必须都用释放时触发或者单击时触发,这是为了保证仅仅触发一次动作. 标准:1.使用简单的case结构模拟事件结构.
- hadoop错误Cannot load libsnappy.so.1 (libsnappy.so.1 cannot open shared object file No such file or directory)!
报如下错误 解决方法: 1.下载libsnappy.so.1(https://yunpan.cn/cSHRHTBJGVVX6 访问密码 c992) 2.上传到linux系统 3.安装 4.安装完成后 ...
- Cocopods -第三方库的管理
前言 什么是CocoaPods? CocoaPods是OS X和iOS下的一个第三类库管理工具,通过CocoaPods工具我们可以为项目添加被称为“Pods”的依赖库(这些类库必须是CocoaPods ...
- HDU-1009(简单贪心)
FatMouse' Trade Problem Description FatMouse prepared M pounds of cat food, ready to trade with the ...
- List和ArrayList,LinkList的区别
接口 List<E> 是一个接口: ArrayList<E> 是一个类:是一个实现了List接口的类,因此可以List里面定义的所有的方法都实现了. 1.ArrayList是实 ...
- c语言训练题:关于张三李四王五说谎的问题(此处用javascript实现)
(第一篇博文) 今天在一个交流群里见他们无聊,然后找到之前收藏的一些c语言题目放出去想让他们做,结果反倒是自己不会做,于是花了很多时间去想. 原题:张三说李四在说谎,李四说王五在说谎,王五说张三和李四 ...