events – How to set a timer in mysql

events – How to set a timer in mysql

You can declare a fixed point in time for the events schedule. The interval part is optional.

Heres an example that appears on manual page http://dev.mysql.com/doc/refman/5.6/en/create-event.html

mysql> CREATE EVENT e_totals
    ->     ON SCHEDULE AT 2006-02-10 23:59:00
    ->     DO INSERT INTO test.totals VALUES (NOW());

Note also that you do not have to use a stored procedure.

You will need a stored procedure to execute the code. It is a place where you can have if/else/white…….working with sp

Then you will need an event to call the procedure at any schedule time.

You have to make sure event-scheduler is turned on in mysql

events – How to set a timer in mysql

Mysql events is good option or you can use database triggers if you have older version of mysql.

http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html
http://www.mysqltutorial.org/mysql-triggers/working-mysql-scheduled-event/

Leave a Reply

Your email address will not be published.