[AccessD] New ID/Autonumber value

Stuart McLachlan stuart at lexacorp.com.pg
Fri May 9 06:51:41 CDT 2003


In Jet 4 it's on a per connection basis. In SQL Server, it's a system 
variable. So it depends on whether you Backend is  Access or SQL 
Server.

If you are using an Acces BE with Jet 4 and only updating one table 
with the connection, it's safe - if it's an SQL Server BE or the same 
connection updates multiple tables in an Acces BE,  it's not.


On 9 May 2003 at 10:35, Gustav Brock wrote:

> Hi Andrew and Stuart et al
> 
> I'm confused!
> 
> Andrew wrote:
> 
> It is safer as  @@Identity is linked only to the connection (or
> transaction) which created the record.  
> 
> Otherwise you are risking that another user will insert a record
> in-between adding and retrieving the ID of the record added by the
> first user.
> 
> I'm not sure if that is a risk using the other methods mentioned on
> this list, however I *do* now that with @@Identity there is no risk of
> this happening.
> 
> but Stuart wrote:
> 
> > @@Identity is a system wide variable. It returns the last autonumber
> > generated by the system. You certainly can't rely on it to return a
> > particular record number in either a multi user system or in a
> > system where you are inserting into more than one table with
> > autonumbers keys in the same transaction.
> 
> So now, what to believe?
> 
> /gustav
> 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com


-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System 
Support.





More information about the AccessD mailing list