views:

19

answers:

2

Hello to all .

Is possible to create a routine or procedure that can automatic everyday check a date in a table.

To be simpler : I want to check if the date on a user have permitions to enter a site and when the date pass want to make the user field activated false.

routine daily check if (todaydate < dateclient) then client.activated= false

Thanks for all the help.

+1  A: 

Yes, this should be a simple UPDATE query. Something like the following:

UPDATE Client
SET Activated = 'false'
WHERE NOW() < dateclient

You would obviously need to modify this for your schema and then schedule it to run daily using cron or an alternative scheduler of your choice.

ar
Thanks for the help .. I see now, there is no sql server automatic routines , the only away is using the system to execute the scripts .
Bruno Silva
A: 

Creating the routine is simple enough, but to run it on a daily basis you'll need to wrap it in a cronjob (*nix) or Scheduled Task (Windows). The routine, unfortunately, cannot execute itself - and to the best of my knowledge MySQL server does not possess the ability to run routines at scheduled intervals.

Brian Driscoll
Thanks , this is the answer I was looking for.
Bruno Silva