首页 > 代码库 > mysql 存储过程中使用事物+事件定时执行存储过程
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 存储过程中使用事物+事件定时执行存储过程
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。