日期:2014-05-18 浏览次数:20483 次
mysql> create procedure pro10() -> begin -> declare i int; -> set i=0; -> while i<5 do -> insert into t1(filed) values(i); -> set i=i+1; -> end while; -> end;// Query OK, 0 rows affected (0.00 sec)
------解决方案--------------------
mysql> create procedure pro11() -> begin -> declare i int default 0; -> repeat -> insert into t1(filed) values(i); -> set i=i+1; -> until i>=5 -> end repeat; -> end;// Query OK, 0 rows affected (0.00 sec) mysql> create procedure pro12() -> begin -> declare i int default 0; -> loop_label: loop -> insert into t1(filed) values(i); -> set i=i+1; -> if i>=5 then -> leave loop_label; -> end if; -> end loop; -> end;//