The transaction works, if you use a lock (read/write exclusive) and
use the select max method, but that is not a good idea on a heavily
trafficed app.
If you are using mssql, you don't need to use a transaction, let me
find the name of that method...
I don't remember the syntax of getting the value, I wouild have to
look up my code, but what you are looking for is @@scopeidentity, not
@@identity. Then a transaction is not needed.
@@scopeidentity gets the last identity inserted, for the current
session/connection.
--
Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040
[EMAIL PROTECTED] - [EMAIL PROTECTED]
http://bighead.net/ - http://eventpix.com/
On Feb 11, 2007, at 12:36 PM, Roland Dumas wrote:
what about creating a transaction, inserting the order, and in the
transaction, asking for ... select <@literal @@identity> .. to get
the order's record number? You're not going to get the same unique
ID for two orders coming in at the same time.
On Feb 11, 2007, at 12:26 PM, Robert Garcia wrote:
Do not make the mistake of doing an insert, and asking for the
last ID doing something like select max(rowid) from table. This
works, but it is NOT full proof. If there are 2 orders happening
at the same time, you can get the wrong value, and have 2 sessions
pointing to the same order. So, create a GUID (guaranteed unique
identifier) and either use that as the order key, or use it to
retrieve the order id if you want to use the nice integer id.
______________________________________________________________________
__
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf