Dominic,

Not really... Databases do a lot of things concurrently. The statement below
"should" be safe, but locking, and other issues on a very busy database
could cause deadlocks if 2 simultaneous processes are trying to update the
same row.

Having said that, I suspect that the "identity" or "autonumber" field is
doing something quite similar to this under the hood. Perhaps Jochem or one
of the other super SQL guru's could tell us more :)

-Mark


-----Original Message-----
From: Dominic Watson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 20, 2007 1:37 PM
To: CF-Talk
Subject: Re: Dynamic ID's

>
> Beware of doing it this way... You will need cftransaction or some 
> other way of ensuring that the ID is unique. Consider the situation 
> where 2 inserts from 2 different people are happening nearly 
> simultaneously. The second request for the max(ID) could occur before 
> the first is inserted....



Is that definately true with the select insert as I exampled? I imagine (but
that is all I do, quite willing to be wrong) that the single SQL statement
must complete before another is allowed to run..? I.e. I imagine that this
SQL will not run into the problem you describe:

INSERT INTO myTable (id, title)
SELECT Max(id) + 1, 'Some title'
FROM myTable

Cheers,

Dominic




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

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

Reply via email to