1. 程式人生 > >備份一個批量插入的儲存過程

備份一個批量插入的儲存過程

懶得每次都要重寫

 

drop procedure if exists insertText;  
delimiter $
create procedure insertText()
    
BEGIN
  
  DECLARE t_error INTEGER DEFAULT 0;    
   declare i int(11);
     DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET t_error=1; 
       set i = 1; 
     START TRANSACTION;
 
  
  loop1: WHILE i <= 100000 DO
  
  /*insert into p_record_charge(cardSerial,carNumber,inTime,chargeTime,payAmount,paidAmount,reduceAmount,paymentType,terminalId,recordInId,
recordOutId,userId,addTime,remarks,employeeId,employeeName,humanId,humanName,customNo,payCategory,
payStatus,couponCustomNo,couponName,couponAmount,appointmentId,reduceType,isRefund,vipRecordId,carCardTypeId,chargeTypeId,
billingTime,chargeTypeName,carCardTypeName) 
values("","京AA0234","2018-06-04 15:51:08","2018-06-04 16:18:35",0.01,0.01,0,0,3,13,890125,1,"2018-06-04 16:20:00","",1,"xxx",
0,"","",0,0,"","",0,0,0,"",0,4,3,1647,"登記臨時車","登記臨時車1");*/
INSERT INTO `p_record_in` ( `cardSerial`, `carNumber`, `chargeTypeId`, `controllerId`, `inTime`, `picPath`, `inType`, `carOwnerType`, `recordStatus`, `carNumberOld`, `employeeId`, `employeeName`, `isManualClear`, `terminalId`, `carModel`, `carColor`, `platePicPath`, `confidence`, `carLogo`, `reserve1`, `reserve2`, `reserve3`, `reserve4`, `addTime`, `updTime`) VALUES 
  ('','京MH5582',1,17,'2018-05-22 09:20:30','null',13,2,0,NULL,0,NULL,0,0,0,NULL,NULL,0,0,NULL,NULL,NULL,NULL,NULL,NULL);

  SET i = i+1;
     END WHILE loop1;
     
  IF t_error = 1 THEN 
         ROLLBACK;  
     ELSE  
         COMMIT;  
     END IF;   
 end $
 delimiter ;