저장 프로세스 미리 처리 대량 삽입 데이터

1256 단어 저장 프로세스
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;

좋은 웹페이지 즐겨찾기