You probably have a race condition, where two people execute the code
at the "same time", and the order goes like this:

A - delete
B - delete
A - insert
B - insert

In this case, you'd expect the fourth statement (the second insert) to
throw the dupe key exception.

cheers,
barneyb

On 9/10/07, Josh Nathanson <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> In an inherited application, we have the following pseudo-code - two
> queries, one right after the other:
>
> <cfquery>
> DELETE FROM table
> WHERE ID = '#myidstring#'
> </cfquery>
>
> <cfquery>
> INSERT INTO table
> (ID)
> VALUES
> ('#myidstring#')
> </cfquery>
>
> Given this scenario, it would seem that you could never have a duplicate key
> error, since you are deleting any rows with the string in question, before
> trying to do an insert.  However, occasionally this throws a "duplicate key"
> error.
>
> Is it possible that somehow the insert occasionally runs before the delete?
> Do I need to use cftransaction to ensure the proper order of execution here?
>

-- 
Barney Boisvert
[EMAIL PROTECTED]
http://www.barneyb.com/

Got Gmail? I have 100 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288116
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to