Question
Does this work when you use <CFINSERT...> or <CFUPDATE...>? thanks!!!
man I love this site!
Posted by: Dano
Posted on: 07/02/2004 08:59 AM
|
Didn't work
I tried this with MS access .. no luck. Looked into the SQL and it seems that this is an only SQL server trick. Ahh man. Back to Select MAX(ID)
MC
Posted by: Mike
Posted on: 11/02/2004 09:56 AM
|
Yup
@@identity is indeed MS SQL Server specific.
Posted by: timo
Posted on: 11/16/2004 05:19 PM
|
mysql
is there any similar variant for this using mysql?
Posted by: tim
Posted on: 12/03/2004 04:33 PM
|
MySQL variant
mysql_insert_id() is the MySQL version of @@identity.
Posted by: Wayne
Posted on: 12/06/2004 09:44 AM
|
setting identity
how can i set a particular field into identity field using mySQlfront. I used mySQL server.
Posted by: dick
Posted on: 02/03/2005 09:31 AM
|
IT DOES work in access.
It works in newer versions of access. I've used it many many times. you need to use 2 cfqueries, and make sure you cftry and cftransaction them together, so the id will allways be correct.
there is also a method like this in mysql. SELECT LAST_INSERT_ID() AS id
Posted by: kevin
Posted on: 02/26/2005 04:26 PM
|
Need help setting identity
Hi there. I cant get this to work. Please instruct on setting up the identity. Thanks!
Posted by: MichaelBlues
Posted on: 02/27/2005 05:16 PM
|
access, mysql
If you are using msAccess (or mysql) you will need to NOT use a ';' and break the query into two seperate queries, which then leads to issues with 'what if two people add a record at the same time' so locking and good checking needs to be used also
Posted by: kevin
Posted on: 04/21/2005 04:34 PM
|
MySQL
It seems not to work for MySQL. Stick to Select max(ID)
Posted by: iqbal
Posted on: 08/01/2005 01:23 AM
|
MySQL
You should select from something unique to that record, max id has nothing to do with a specific record.
The best way is to select exactly what you inserted. If there is the possibility of identical rows, add a UUID to each row. the only surefire way to make this multi thread safe is to select exactly what was inserted with a UUID also.
Posted by: Kevin
Posted on: 11/24/2006 07:56 PM
|
WHy NOT?
If you are unable to use this method why not just use two separate queries. You still have the data from the form just inserted, you can still use it.
<cfquery name="qGetUser" datasource="MyDSN"> INSERT INTO users (firstName, lastName, email ) VALUES ( '#FORM.LastName#', '#FORM.LastName#', '#FORM.email#' ); </cfquery>
<cfquery name="getID" datasource="MyDSN"> SELECT member_id FROM users WHERE (firstName = #Form.firstName ) AND ( lastName = '#Form.LastName'); </cfquery>
Posted by: holmes
Posted on: 05/18/2007 01:08 PM
|