create procedure pro_employee()
begin
declare i int default 50;
while(i<=50) do
set i=i-1;
if i>=10 then
insert into t_employee(empName,positionId)values(concat('雇员',i),floor(i/10));
end if;
end while;
select empName,positionId from t_employee;
end
drop procedure if exists pro_employee;
call pro_employee();[SQL]call pro_employee();
[Err] 2013 - Lost connection to MySQL server during query
插入的数据会迅速增长,停下来 ;原意是空产生40条数据的 ,现在是进入了死循环
begin
declare i int default 50;
while(i<=50) do
set i=i-1;
if i>=10 then
insert into t_employee(empName,positionId)values(concat('雇员',i),floor(i/10));
end if;
end while;
select empName,positionId from t_employee;
end
drop procedure if exists pro_employee;
call pro_employee();[SQL]call pro_employee();
[Err] 2013 - Lost connection to MySQL server during query
插入的数据会迅速增长,停下来 ;原意是空产生40条数据的 ,现在是进入了死循环
解决方案 »
- 求大神帮忙解下sql的一个查询的题。。。
- timestamp类型转换
- 关于一个查询问题(新手没多少积分,先请谅解)
- sql语句查询问题,根据外部条件和字段信息进行查询
- Microsoft SQL Server中关于时间查询
- 请问这语法有错吗?为何不能执行?
- 求高分解决一个SQL中的存储过程问题!!回答者都有分拿~~
- 高分求:只用存储过程创建MDB(ACCESS数据库)的语句
- 项目要求分类排序查询并要求只显示每一类前10条记录~SQL怎么写?
- SOS,SQL 20000 B/S结构,可以SELECT ,不能INSERT及UPDATE,但权限应该都设好了啊!(ERROR如下:)
- 在SQL表中删除一条记录,该如何操作呢?
- 数据库还原后出现中文乱码
set i=i-1;
这个条件,会永远成立的 ;
你要改成
while (i>=0) do ,就可以了;
然后下面的If 可以直接去掉就可以了
i<=50
你去减i
i永远小于等于50你写的就是死循环