外观
LOOP 语句
LOOP语句没有循环条件,但是可以通过LEAVE语句退出循环。
LOOP语句的语法如下:
label:loop
...
end loop;LOOP允许某特定语句或语句群的重复执行,实现一个简单的循环构造,中间省略的部分是要重复执行的语句,退出循环用LEAVE语句,语法为LEAVE label。
如:
delimiter //
create procedure example_loop(in x int)
begin
label:loop
if x>5 then leave label;
end if;
select x;
set x = x+1;
end loop;
end
//