1

Suppose the current date is 20141110 10:00pm , I would like to let mysql to update a field and then dump few fields into a file while the date is 20141201 10:00pm

how to implement it?

What I know is to use event, but this seems to be used under some interval time. like every few hours/days/weeks to make the event happen.

Bright Liu
  • 57
  • 1
  • 1
  • 8

3 Answers3

2

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

Here's 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.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
0

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

Jaylen
  • 39,043
  • 40
  • 128
  • 221
-1

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/

Dhruv Kapatel
  • 873
  • 3
  • 14
  • 27