天天看點

mysql 事件

set global event_scheduler =1;  

DROP PROCEDURE IF EXISTS transDataProcedure;

CREATE PROCEDURE transDataProcedure()

BEGIN

REPLACE INTO cathy_rh.tbl_case_scanc_temp() SELECT * FROM cathyjcy.tbl_case_scanc_temp ct where ct.enabled_flag = 1;

UPDATE cathy_rh.tbl_case_scanction c SET c.enabled_flag = 0 where c.TEMP_CASE_ID IN(SELECT ct.ID FROM cathyjcy.tbl_case_scanc_temp ct where ct.enabled_flag = 1 and ct.DELETE_FLAG = 1);

UPDATE cathyjcy.tbl_case_scanc_temp ct SET ct.enabled_flag = 0 where ct.enabled_flag = 1;

END;

create event if not exists EVENT_TRANS_DATA

on schedule every 1 HOUR  

on completion preserve  

do call transDataProcedure();  

alter event EVENT_TRANS_DATA ON COMPLETION PRESERVE ENABLE; 

繼續閱讀