MySQL timed tasks for stored procedures and scheduled tasks

Source: Internet
Author: User

Demand:

The message in T_app_message (the message that will be sent) needs to be sent to each student once, and the message is sent to the sent state after the send is complete.

A word does not fit the code

1 /*To Delete a stored procedure*/2 Drop procedure if existsproc_sendallmsg;3 /*create a stored procedure*/ 4 CREATE PROCEDUREproc_sendallmsg ()5 BEGIN6 /*Insert First*/7 INSERTt_base_message (Sid,mid)8 SELECTA.id,b.id fromT_base_student a9 INNER JOINT_app_message bTen wherea.school_id= 1  andB.sendtime<=Now () andB.sendstatus= 0; One UPDATET_app_messageSETSendstatus= 1 whereSendtime<=Now (); A UPDATET_app_messageSETShowstatus= 1 whereEndtime<=Now (); - End  -  the /*Specify the database*/  -  UseXSCP; - /*Delete an existing scheduled task*/ - DropEventif existsevent_sendallmsg;  +  - CREATEEVENT event_sendallmsg onSCHEDULE every -Second starts'2017-12-11 00:00:00'  +  Do ACall proc_sendallmsg; /* Call the stored procedure */

MySQL timed tasks for stored procedures and scheduled tasks

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.