Ask a Question related to Coldfusion Database Access, Design and Development.
-
JoeyTMann #1
Re: returning an inserted SQL record
Found my answer...
Select max(column) as ID
from table
JoeyTMann Guest
-
Inserting a timestamp when record is inserted
Hi, how would I have a form insert a timestamp when the form was submitted for update into a table. I know there is a timestamp column type but I... -
ID of last record inserted
Is it possible, with a MS Access database, to pull the ID of a record just inserted? I have found various threads and tutorials on various sites... -
Accepted way to grab the ID of a record you have just inserted?
I have a page that inserts a new record into a DB. Upon doing so, I want to refresh the page and return the data that was just entered (including... -
Identity from inserted record
I'm inserting a record into a SQL Server database. Once the record has been added, I need the Identity value that SQL Server created. Normally, the... -
mySQL / Last inserted record ID
Hi, I'm using mySQL and wanted to get the ID of the record that I have just inserted in to the table (sentmessages). There is a function in mySQL... -
paross1 #2
Re: returning an inserted SQL record
You need to be real careful with this method, especially if you have a busy
site, as you may "grab" the wrong ID if another user happens to perform an
insert at the same time. One way that you can manage this is by using
CFTRANSACTION to include the insert and select within the same transaction.
Phil
paross1 Guest
-
BigDMorris #3
Re: returning an inserted SQL record
Actually, here's the right way to do it in SQL Server without requiring another
database read and the possibility of another user slipping in and giving you
the wrong ID. This is the official way of doing it. It took me years to find
this, but it works every time: <CFQUERY NAME='LastValue' etc.> SET Nocount
ON; INSERT INTO MyTable (blahblah) VALUES(blahblah); SELECT
@@IDENTITY AS LastID; SET Nocount OFF; </CFQUERY> <!--Identity:
#LastValue.LastID#--> Dave Morris
BigDMorris Guest



Reply With Quote

