日期:2014-05-16 浏览次数:20427 次
CREATE PROCEDURE `proc_name`(in types integer) begin DECLARE ctime int(11); DECLARE goal int(11); set ctime =1; set @sqltext='insert into test(title,direct,clicktime,mtype,goal) values'; loop1: WHILE ctime<=15 DO set goal=1; loop2: WHILE goal<=100 DO if ctime=15 and goal=100 then set @sqltext =concat(@sqltext,'(',CONCAT('''diezhongdie',types*1000+ctime*100+goal,''''),',',CONCAT('''haidong',types*1000+ctime*100+goal,''''),',',ctime,',',types,',',goal,')'); else set @sqltext =concat(@sqltext,'(',CONCAT('''diezhongdie',types*1000+ctime*100+goal,''''),',',CONCAT('''haidong',types*1000+ctime*100+goal,''''),',',ctime,',',types,',',goal,'),'); end if; set goal=goal+1; END WHILE loop2; set ctime=ctime+1; END WHILE loop1; prepare stmt from @sqltext; execute stmt; DEALLOCATE PREPARE stmt; set @sqltext=''; end;
?