mysql 存储过程中使用事物+事件定时执行存储过程
Posted 否定之否定
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 存储过程中使用事物+事件定时执行存储过程相关的知识,希望对你有一定的参考价值。
(1)存储过程
DROP PROCEDURE IF EXISTS proc_test; CREATE PROCEDURE proc_test() BEGIN DECLARE t_error INTEGER DEFAULT 0; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET t_error=1; START TRANSACTION; insert into score_record_bak(openid, nickname, city_id, city_name, grid_number, score_type, channel_manager_score, channel_manager_remark, railcom_support_score, railcom_support_remark, manager_support_score, manager_support_remark, insert_time, weixin_accountid) select openid, nickname, city_id, city_name, grid_number, score_type, channel_manager_score, channel_manager_remark, railcom_support_score, railcom_support_remark, manager_support_score, manager_support_remark, insert_time, weixin_accountid from score_record; DELETE from dezhou_score_record; IF t_error = 1 THEN ROLLBACK; ELSE COMMIT; END IF; END;
(2)事件
定时执行存储过程
CREATE EVENT if not exists e_dezhou_score_record
ON SCHEDULE EVERY 1 MONTH STARTS ‘2017-05-01 00:00:00‘
ON COMPLETION NOT PRESERVE ENABLE
DO CALL proc_test();
以上是关于mysql 存储过程中使用事物+事件定时执行存储过程的主要内容,如果未能解决你的问题,请参考以下文章