存储过程

http://blog.csdn.net/hbcui1984/archive/2006/10/18/1340179.aspx

http://blog.csdn.net/xuezj508/archive/2007/04/15/1565372.aspx

http://blog.csdn.net/LEOlws/archive/2006/12/27/1465128.aspx

[label:] REPEAT

statements

UNTIL expression

END REPEAT [label] ;


[label:] LOOP

statements

END LOOP [label];


[label:] WHILE expression DO

statements

END WHILE [label] ;

-------------------
DELETE FROM tbl_name WHERE 1>0;

注意这比没有WHERE子句的DELETE FROM tbl_name慢的多了,因为它一次删除一行
可以加上limit


repeat
fetch next from test_cur into idd,datetime,type,count;
set tt=tt+1;
insert into test.event (datetime,type,count) values('2','2',2);
UNTIL (tt>10)  //直到大于十为止
end repeat;

--------------------
while(tt<10) do
fetch next from test_cur into idd,datetime,type,count;
set tt=tt+1;
insert into test.event (datetime,type,count) values('2','2',2);
end while;


---------------
begin
declare idd int(10);
declare tt int(10);
declare datetime varchar(200);
declare type varchar(200);
declare count int(10);
declare test_cur cursor for select id,datetime,type,count from test.event;
open test_cur;
set tt=1;

repeat
fetch next from test_cur into idd,datetime,type,count;
set tt=tt+1;
insert into test.event (datetime,type,count) values('2','2',2);
UNTIL (tt>10)
end repeat;
close test_cur;

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值