Mysql问题及解决——Error code2014
2015-12-10 22:24
609 查看
问题描述:
使用mysql workbench执行一段存储过程,如下,实现分段插入的功能,但是会出现Error Code: 2014 Commands out of sync; you can't run this command now,
设定SQL editor——Query Editor——Max number of result set:从10改到500,会出现同样的错误,但是出现的时间不一样。
同样的代码在navicat上实现没有问题。
CREATE DEFINER=`root`@`localhost` PROCEDURE `test`()
BEGIN
#Routine body goes here...
DECLARE no_more_record INT DEFAULT 0;
DECLARE session_record text;
DECLARE numberofid int DEFAULT 0;
declare nmbid int default 0;
DECLARE cur_record CURSOR for select distinct session_trace from exact_reg_users;#the important part
#DECLARE cur_record CURSOR for select ordertime from cookie_order;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_record = 1; /*这个是个条件处理,针对NOT FOUND的条件,当没有记录时赋值为1*/
open cur_record;
fetch cur_record into session_record;
drop table if exists cookie_to_id;
create table if not exists cookie_to_id
(
id VARCHAR(255),
session_changed_users VARCHAR(255)
);
set @numberofid=1;
while no_more_record !=1 DO
fetch cur_record into session_record;
select session_record;
SELECT DISTINCT tuniu_user_id,session_trace FROM webflow1207 where session_trace = session_record;
select @numberofid:=COUNT(DISTINCT tuniu_user_id) from webflow1207 where session_trace = session_record;
/*if @numberofid = 2 then
INSERT into cookie_to_id(id,session_changed_users)
SELECT DISTINCT tuniu_user_id,session_trace FROM webflow1207 where session_trace = session_record;
SELECT "insert success";
end if;*/
end WHILE;
CLOSE cur_record;
END
解决方法:
尚不明确。
使用mysql workbench执行一段存储过程,如下,实现分段插入的功能,但是会出现Error Code: 2014 Commands out of sync; you can't run this command now,
设定SQL editor——Query Editor——Max number of result set:从10改到500,会出现同样的错误,但是出现的时间不一样。
同样的代码在navicat上实现没有问题。
CREATE DEFINER=`root`@`localhost` PROCEDURE `test`()
BEGIN
#Routine body goes here...
DECLARE no_more_record INT DEFAULT 0;
DECLARE session_record text;
DECLARE numberofid int DEFAULT 0;
declare nmbid int default 0;
DECLARE cur_record CURSOR for select distinct session_trace from exact_reg_users;#the important part
#DECLARE cur_record CURSOR for select ordertime from cookie_order;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_record = 1; /*这个是个条件处理,针对NOT FOUND的条件,当没有记录时赋值为1*/
open cur_record;
fetch cur_record into session_record;
drop table if exists cookie_to_id;
create table if not exists cookie_to_id
(
id VARCHAR(255),
session_changed_users VARCHAR(255)
);
set @numberofid=1;
while no_more_record !=1 DO
fetch cur_record into session_record;
select session_record;
SELECT DISTINCT tuniu_user_id,session_trace FROM webflow1207 where session_trace = session_record;
select @numberofid:=COUNT(DISTINCT tuniu_user_id) from webflow1207 where session_trace = session_record;
/*if @numberofid = 2 then
INSERT into cookie_to_id(id,session_changed_users)
SELECT DISTINCT tuniu_user_id,session_trace FROM webflow1207 where session_trace = session_record;
SELECT "insert success";
end if;*/
end WHILE;
CLOSE cur_record;
END
解决方法:
尚不明确。
相关文章推荐
- mysql优化测试
- mysql之视图
- mysql-测试环境对比生产环境-表、存储过程
- mysql 主从配置
- mysql5.6.12切换binlog二进制日志路径
- 【MySQL】行长度的一些限制
- JDBC 连接MySQL的使用。
- mysql安装后简单的配置(以5.6.22 x64为示例)
- 解决MySQL错误reading initial communication packet_MySQL的两种方法
- mysql 中的bit数据类型
- mysql函数之比较函数
- mysql命令
- MYSQL截取列里面的数据为多行
- mysql索引总结----mysql 索引类型以及创建
- mysql基础语句
- Mysql 更新、删除字段、自增长字段
- 阿里云下mysql远程访问被拒绝
- mysql.user表root用户
- 10015---MySQL--事务
- mysql ndbcluster设置root用户和远程登录