首页 > 代码库 > mysql event
mysql event
推荐看:
http://blog.csdn.net/jesseyoung/article/details/35257527
SET GLOBAL event_scheduler = ON;
drop procedure if exists p_insmrgnrate_update;
create PROCEDURE p_insmrgnrate_update()
BEGIN
DECLARE count_num INT DEFAULT 0;
SET SQL_SAFE_UPDATES = 0;
update t_insmrgnrate set tradingday=date_add(CURDATE(), interval 1 day)+0 where tradingday=
(SELECT a.tradingday FROM (SELECT tradingday from t_insmrgnrate GROUP BY tradingday ORDER BY tradingday desc LIMIT 0,1) a);
update t_insmrgnrate set tradingday=CURDATE()+0 where tradingday=
(SELECT a.tradingday FROM (SELECT tradingday from t_insmrgnrate GROUP BY tradingday ORDER BY tradingday desc LIMIT 1,1) a);
update t_insmrgnrate set tradingday=date_sub(CURDATE(), interval 1 day)+0 where tradingday=
(SELECT a.tradingday FROM (SELECT tradingday from t_insmrgnrate GROUP BY tradingday ORDER BY tradingday desc LIMIT 2,1) a);
END;
DROP EVENT IF EXISTS event_insmrgnrate_update;
create EVENT event_insmrgnrate_update
ON SCHEDULE EVERY 1 MINUTE STARTS ‘2017-06-08 08:00:00‘
ON COMPLETION PRESERVE
ENABLE
DO
call p_insmrgnrate_update;
mysql event