DELIMITER $$ CREATE DEFINER=`root`@`localhost` EVENT `job_update_status` ON SCHEDULE #修改以下调度信息 EVERY 5 minute STARTS now() ON COMPLETION PRESERVE ENABLE DO BEGIN DECLARE r_code CHAR(5) DEFAULT '00000'; DECLARE r_msg TEXT; DECLARE v_error INTEGER; DECLARE v_starttime DATETIME DEFAULT NOW(); DECLARE v_randno INTEGER DEFAULT FLOOR(RAND()*100001);
INSERT INTO mysql.t_event_history (dbname,eventname,starttime,randno) #修改下面的作业名(该作业的名称) VALUES(DATABASE(),'job_update_status', v_starttime,v_randno);
UPDATE mysql.t_event_history SET endtime=NOW(),issuccess=ISNULL(v_error),duration=TIMESTAMPDIFF(SECOND,starttime,NOW()), errormessage=CONCAT('error=',r_code,', message=',r_msg),randno=NULL WHERE starttime=v_starttime AND randno=v_randno;