Use things + events to execute stored procedures in MySQL stored procedure

Source: Internet
Author: User
Tags openid

(1) Stored procedures

DROP PROCEDURE IF EXISTSproc_test;CREATE  PROCEDUREproc_test ()BEGIN  DECLARET_errorINTEGER DEFAULT 0; DECLARE CONTINUEHANDLER forSQLEXCEPTIONSETT_error=1; STARTTRANSACTION; Insert  intoScore_record_bak (OpenID, nickname, city_id, City_name, Grid_number, Score_type, Channel_manager_score, Channel_ma Nager_remark, Railcom_support_score, Railcom_support_remark, Manager_support_score, Manager_support_remark, Insert_ Time, Weixin_accountid)SelectOpenID, nickname, city_id, City_name, Grid_number, Score_type, Channel_manager_score, Channel_manager_remark, rail Com_support_score, Railcom_support_remark, Manager_support_score, Manager_support_remark, Insert_time, Weixin_ AccountId fromScore_record; DELETE  fromDezhou_score_record; IFT_error= 1  Then          ROLLBACK; ELSE          COMMIT; END IF; END;

(2) Event

Timed execution of stored procedures
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 ();

Use things + events to execute stored procedures in MySQL stored procedure

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.