CREATE PROCEDURE ` init_president_day ` (in startTimeV VARCHAR (30), in endTimeV VARCHAR (30))
The begin
Declare groupbuySum decimal (12, 2);
Declare vidtmp int (12);
Declare startTime DATETIME DEFAULT DATE_FORMAT (startTimeV, '% Y % m % d).
Declare endTime DATETIME DEFAULT DATE_FORMAT (endTimeV, '% Y % m % d).
Declare startTimeStr VARCHAR (20);
- terminated traversal data
DECLARE the done INT the DEFAULT FALSE;
/* declare cursor */
DECLARE the rs CURSOR FOR the SELECT vid FROM t_manager_village where vid=80;
- will end symbol is bound to the cursor
DECLARE the CONTINUE HANDLER FOR the NOT FOUND SET done=TRUE;
- open the cursor
OPEN the rs;
- traversal
Read_loop: LOOP
- values in multiple fields
The FETCH NEXT from rs INTO vidtmp;
IF done THEN
LEAVE read_loop;
END the IF;
- business
Set startTime=DATE_FORMAT (startTimeV, '% Y % m % d).
While startTime
Select ifnull (sum (the sum), 0) into groupbuySum from t_groupbuyorder where pay_time is not null and DATE_FORMAT (pay_time, '% % m % d Y)=startTimeStr and vid=vidtmp;
The set startTime=date_add (startTime, interval 1 day);
End the while;
END LOOP;
CLOSE the rs.
END
CodePudding user response:
FETCH the rs INTO vidtmp;Is not the case?