ITPub博客

首页 > Linux操作系统 > Linux操作系统 > mysql 的procedure 中 loop循环的用法。

mysql 的procedure 中 loop循环的用法。

原创 Linux操作系统 作者:season0891 时间:2008-08-28 16:25:17 0 删除 编辑

 create procedure p1()
 begin
 set @x=year(curdate());
 label1:loop
 if @x < 2100 then
 begin
   set @x=@x+1;
   iterate label1;
 end;
 end if;
 leave label1;
 end loop label1;
 select @x;
 end;//

 create procedure p1()
 begin
 set @x=1000000;
 label1:loop
 if @x >0 then
 begin
   set @x=@x-1;
   insert into testing set name='testingdata';
   select @x;
   iterate label1;
 end;
 end if;
 leave label1;
 end loop label1;
 end;//

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/90618/viewspace-438676/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-06-10

  • 博文量
    790
  • 访问量
    2098040