What would be the easiest way to obtain the auto-number of a record that you just inserted? Would it be to do a select query for that record? I need the auto-number to put it into another table.
Thanks for the tip. Using the sql statement below does work.
Code:
select @@IDENTITY as new_value
But in a multi-user environment, how do I make sure that there is no other insertion before I run the statement above? Is that something to do with locking the database?
If it is via an ADO.Recordset rst.AddNew and then populate the fields then after rst.Update the value rst!AutoNumFieldName will contain the new value you need.
And that is robust in a multiuser environment.
'ope-that-'elps.
G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
I am doing it through coldfusion's sql query. I have found out that I can specify the two queries (one to insert and the other to obtain the record number) as a transaction. This way prevents other queries from messing up with my request.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.