How to execute query at the turn of the day?

Asked

Viewed 54 times

-1

I wonder if there’s any trigger or process that I can at the turn of the day 00:00 change the status of installments that have their respective maturity dates greater than hoje(). Any suggestions?

1 answer

2

You can use a feature from MySqlcalled Event. In a simple way a Event is a script that you set up to run from time to time.

The event below will run every day at 00:20, the date given is the date from the day the event will start...

CREATE EVENT nome_evento
   ON SCHEDULE 
     EVERY 1 DAY
     STARTS '2016-06-12 00:20:00' ON COMPLETION PRESERVE ENABLE
  DO
    #AÇÃO A SER REALIZADA

I suggest the following readings:

Article Percona

Mysql documentation

Example source

  • Do not forget that you have to enable the resource in the database with SET GLOBAL event_scheduler = ON;

  • @Sorack is true... srrsrsrs

  • !!!!Thank you!!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.