Name: careydog Date: December 14, 2007 at 17:52:18 Pacific Subject: Delete SQL Table data automatically OS: // CPU/Ram: // Model/Manufacturer: //
Comment:
I am building an online job app where managers of a store can post job listings. I would like to give them the options when they post the job to have the posting up for a specified amount of time (they will be able to choose the end date, and the job will be deleted from the database). Is there a way to tell sql to delete table entries on a certain date? I was also thinking just making this a server function (create and run a bash script), but this doesn't seem like the best way. Any input would be greatly appreciated.
It would depend on the database. MySQL has its own cron job equivalent, for example.
Outside of some sort of scheduling system, I think you'd have to write a stored procedure, or modify your SELECTs to include something like WHERE exp_date > SYSDATE.
Or modify your SELECTs and set up a scheduled purge. That's probably what I'd do.
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE