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 ...
 
随机推荐
- polygonal approximation
			
Several methods and codes in the website: https://sites.google.com/site/dilipprasad/source-codes TRA ...
 - linux下so动态库一些不为人知的秘密 系列
			
http://blog.chinaunix.net/uid-27105712-id-3313293.html http://www.cnblogs.com/gulvzhe/archive/2012/0 ...
 - Android(java)学习笔记196:Android中Menu的使用(静态和动态)
			
1.使用xml定义Menu(静态方法) 菜单资源文件必须放在res/menu目录中.菜单资源文件必须使用<menu>标签作为根节点.除了<menu>标签外,还有另外两个标签用于 ...
 - System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)
			
创建你的一个web server,然后将这个实例制成你的AMI,通过启动配置生成一个Auto Scaling组(包括scale-in/scale-out策略),配置一台Load Balancer指向你 ...
 - microchip PIC芯片使用方法
			
pickit3调试器使用: http://www.eeboard.com/evaluation/pickit3debug/1/ MPLAB环境使用: 1.代码折叠功能 2.代码补全功能 3.函数跳转功 ...
 - 类似与三元表达式的  json  读取值
			
需要先在项目中添加 json的dll json 序列里面的key在item.feeType里面必须存在 否则会报 未将对象引用到实例 myDr["feeType"] = Newto ...
 - C#中方法的参数修饰符
			
做项目久了,有的时候真的需要静下心来认真的总结一下自己所用到的技术,而不是每天依葫芦画瓢,每天忙忙碌碌,到头来不知道自己忙了个啥,学了什么,自己到底掌握了多少知识.所以我想回顾一下C#的基础知识,把重 ...
 - MongoDB 3.0安全权限访问控制(Windows版)
			
MongoDB 3.0安全权限访问控制(Windows版) 1.首先,不使用 –auth 参数,启动 mongoDB: mongod --dbpath "d:\mongodb\data\db ...
 - FragmentTransaction.addToBackStack无效的问题
			
FragmentTransaction.addToBackStack无效的问题: 如果当前的类继承的ActionBarActivity,则FragmentManager必须来自v4包,这样addToB ...
 - 收集SQLServer线程等待信息
			
要知道线程等待时间是制约SQL Server效率的重要原因,这一个随笔中将学习怎样收集SQL Server中的线程等待时间,类型等信息,这些信息是进行数据库优化的依据. sys.dm_os_wait_ ...