函数:
DELIMITER $$
CREATE DEFINER=`hotshopuser`@`%` PROCEDURE `stat_day_report`(sub_day int)
BEGIN
#执行内容
END;
存储过程:
DELIMITER $$
CREATE DEFINER=`hotshopuser`@`%` PROCEDURE `test`(sub_day int)
DETERMINISTIC
BEGIN
#执行内容
declare i int;
set i = 1;
while i < sub_day do
call stat_day_report(i);
set i = i+1;
end while;
END
定时任务:
CREATE EVENT `day_report_job`
ON SCHEDULE EVERY 1 DAY STARTS '2016-03-08 15:41:00'
ON COMPLETION PRESERVE
ENABLE
do call stat_day_report(1);