直接上代码:
-- 使用loop和level循环
delimiter $
drop procedure if exists pro_test8;
create procedure pro_test8(in n int)
BEGIN
declare totle int default 0;
c:loop
set totle = totle + n;
set n = n - 1;
if n <= 0 THEN
level c;
end if;
end loop c;
select totle;
end
$
报错信息如下:
[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 'c;
end if;
end loop c;
select totle;
end' at line 8
本文探讨了在MySQL中创建存储过程时遇到的语法错误,具体是在使用LOOP和LEAVE语句时出现的错误信息。通过分析错误代码,指出了在自定义循环中常见的语法误区,并提供了正确的语法示例。
1618

被折叠的 条评论
为什么被折叠?



