首页 > 数据库 >【MySQL】MySQL 执行包含创建变量的存储过程需要执行两次的解决方法

【MySQL】MySQL 执行包含创建变量的存储过程需要执行两次的解决方法

时间:2022-10-13 00:44:06浏览次数:47  
标签:存储 set end while1 报错 MySQL table 执行

代码:

报错代码

设置mysql分隔符为//
delimiter // 
drop procedure if exists while1;
create procedure while1()
begin
declare i int default 0;
set i = 0 ;
while i < 10 do
insert into test_table(tname) values('TestName1');
set i = i + 1 ;
end while;
select * from test_table;
end 
// 
call while1();
delimiter ;

报错内容

Error Code: 2014 Commands out of sync; you can't run this command now

标签:存储,set,end,while1,报错,MySQL,table,执行
From: https://www.cnblogs.com/HookDing/p/16786649.html

相关文章