Updating a variable based on checking expiration date against now() in each row of a table
I’m using Coldfusion 9,0,0,251028 on Windows 7 64-bit, with a Microsoft Access 97 database.
I’m trying to create a query which loops through all the rows in a table and checks if the current date is later or earlier than the expiration date.
If the expiration date column is earlier than now(), it sets the column “is_current” to 0, which is a variable that controls whether or not a message displays on a different page(breakingnews.cfm).
The column that has the expiration date is “exp_dat” in the table “news”. The query I have so far is:
<cfquery name="expire" datasource="#db#">
update news
set is_current = 0
where exp_dat < now()
</cfquery>
What this ends up doing is filtering out the expired items correctly, but once a new row is inserted, the previous items(which haven’t expired yet)
are still having the “is_current” column set to 0.
The query is cfincluded on the page the messages are supposed to display on (breakingnews.cfm).
How can I get the query to loop over each row every time to check if the now() is earlier or later than “exp_dat” without setting all the other row’s “is_current” to 0?
