【求助帖】存储过程执行loop循环过程失败

直接上代码:

-- 使用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

你可能感兴趣的:(存储过程,loop循环)