|
From: Lionel B. <lio...@bo...> - 2007-01-20 22:55:41
|
Dan Faerch wrote the following on 20.01.2007 23:28 : > Lionel Bouton wrote: > >>> Like this: >>> SELECT. >>> >>> >>> >> I don't really understand what you meant with this SELECT. >> >> >> > Select * from whatever WHERE last_cleanup < sumthing-sumthing. > You need to select the last cleanup time, to be able to compare if > another sqlgrey already did it. > Just to make sure we understand each other: You only need to SELECT the "last_cleanup" value once after each attempted cleanup (and on startup). You then compute the next "expected" cleanup value (simply by adding the delay). On each mail to process, you check if now > "expected" and only try the update with the UPDATE ... SQL statement when this is true. Whatever happens (0 or 1 row updated) you have to refresh the "last_cleanup" value to compute the next "expected" cleanup value. So you SELECT the actual "last_cleanup" value again if the update didn't affect any row or use the one you gave in the update in the other case. > But i guess i need to know if "affected rows" work on all sql's? > > It does, it is standard SQL to return the number of affected rows for each UPDATE statement. At least it worked for me on Oracle, DB2, MySQL, PostgreSQL and SQLite last time I checked (SQLite is in fact out of scope, I can't imagine people running several SQLgreys against one SQLite DB...). Lionel, who should really, really start packing for his trip tomorrow. |