On 9/23/02, jon hall penned:
> Using CF5, I have a database insert that I need to pause a few
> seconds, then select a value back out that is updated from withing
> the db. My code looks something like this:
>
> <cfquery .../> // Insert Query
> <cfset name = Hash(CreateUUID())/>
> <cflock name="#name#" type="readonly" timeout="1">
> <cflock name="#name#" type="exclusive" timeout="5"
>throwontimeout="No"></cflock>
> </cflock>
> <cfquery .../> // Select Query
>
> What is strange is that the second query is not executing after the
> cflock times out. It seems that it must be executing _before_ the
> cflock starts! The database usually takes about 1 second to update
> the field, and even if I set the timeout to 20 seconds the recordset
> returned always contains data that would indicate that the query
> didn't wait until the cflock timed out, but executed before the
> cflock...
I'm not exactly sure if I'm reading your post correctly, but if you
simply want some code to delay executing for a set amount of time,
you can use a conditional loop. CFLOCK doesn't actually lock the code
at that point for the timeout value. The timeout value is how long CF
will wait until either throwing an error or moving on to the next
section of code.
In the same below, the Select query will run 5 seconds after the Code
to activate database Update.
<cftry>
<cflock name="mylockname" timeout="10" type="exclusive" throwontimeout="yes">
<cfset tick = now()>
Code to activate database Update begins at
<CFOUTPUT>#TimeFormat(tick, "h:mm:ss")#</CFOUTPUT><p>
<cfloop condition="(#datediff('S', tick, now())# LT 5)"></cfloop>
Select query runs at <CFOUTPUT>#TimeFormat(now(), "h:mm:ss")#</CFOUTPUT>
</cflock>
<cfcatch type="lock">
The process timed out. Try again.
</cfcatch>
</cftry>
--
Bud Schneehagen - Tropical Web Creations
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED]
http://www.twcreations.com/
954.721.3452
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists