[thelist] ASP - Access
rudy
r937 at interlog.com
Mon Oct 28 15:29:01 CST 2002
> I used to make a query and get the id number of the last record,
> but that gave me problems, because several users will be introducing
> data at the same time.
quite so
this is the "select max(id)" technique and requires a transaction block so
that the insert and select are single-threaded
with microsoft technology, use @@IDENTITY instead
other databases have similar special functions
another technique, which i call "querying back the real primary key," is
based on the assumption that the table has some column or columns that are
unique
when you think about it, the autonumber is actually a surrogate key
the table will usually have some other candidate key that you could call
the "real" primary key
when the form provides values for the table's columns, and you insert a new
row with these values, all you have to do is just query back the row using
the "real" pk column value(s) just inserted
note: this technique does *not* require a transaction block
example here --
Retrieving last row inserted
http://searchdatabase.techtarget.com/ateQuestionNResponse/0,289625,sid13_ci
d464176_tax285649,00.html
rudy
More information about the thelist
mailing list