HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

automatically change value on the table mysql

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
theautomaticallyvaluemysqlchangetable

Problem

i have table invoice in my database that contain atributes 'due date', 'date' and 'status'. What i want is data on 'status' change automatically. Example, status (unpaid change to expired) when date past the due date. Does it make sense ?

Solution

There are two ways to do this. The more traditional way is with a cron job on the server:

http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5

Another way is to do it with MySQL events:

https://dev.mysql.com/doc/refman/5.6/en/events.html

I personally prefer to keep this kind of logic in the app via a cron job and keep mysql events dedicated to db maintenance related items (partition maintenance for instance).

Context

StackExchange Database Administrators Q#105898, answer score: 2

Revisions (0)

No revisions yet.