Russ wrote:
> So exactly how would I use something like this? I started with saying
> server locking, but the best thing would be...
>
> <cfquery name="myqry" datasource="mydsn">
> Select top 1000 * from emailQueue with (updlock) where isSent=0
> </cfquery>
>
> and for that query to return different things on different servers.
> Basically, I guess what I'm looking for is
>
> select top 1000 * from emailQueue where isSent=0 and ROW IS NOT LOCKED.
I typically use something like:
<cfquery all>
SELECT pk
FROM table
WHERE finished = FALSE
</cfquery>
<cfloop all>
<cftry>
<cftransaction>
<cfquery record>
SELECT *
FROM table
WHERE pk = #all.pk#
AND finished = FALSE
FOR UPDATE NOWAIT
</cfquery>
do something (email, ftp, etc)
<cfquery>
UPDATE table
SET finished = TRUE
WHERE pk = #all.pk#
</cfquery>
</cftransaction>
<cfcatch type="db">
</cfcatch>
</cftry>
</cfloop>
Jochem
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:231677
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54