try this right after your insert query: SELECT LAST_INSERT_ID() AS id
(check out this page for the full explanation, should help you get what you want) http://tutorial174.easycfm.com/ HTH On Nov 28, 2007 7:18 PM, Randi Knutson <[EMAIL PROTECTED]> wrote: > Couple of ideas for you: > > Don't delete records. Create a "deleted" field and mark them deleted. > > If you are trying to find out the record number of a newly inserted > record, you can wrap your insert in cftransaction, and then run a "select > @@identity from table" before /cftransaction (that's SQLServer, might be > different syntax for you.) > > You can also reset the identity field if you really really need to. See > the article at > http://www.quantumsoftware.com.au/Support/KB/Article.aspx?ID=125 > > Okay I guess I did not really answer your question, but this is the best > answer I have. > > [email protected] on Wednesday, November 28, 2007 at 5:07 PM > -0800 wrote: > >I am using ColdFusion MX 7.0 with a MySQL database. > > > >One of my tables has an autoincrement field called "intKey" (without the > >quotes, obviously) as the key. > > > >Is there a way to programatically determine the number of the next record > >that will be added to the database? > > > >For example, if I have ten records (with keys of 1 through 10) and I > >delete records 8, 9, and 10, the next record that will be inserted will > >be 11. Therefore it's not a matter of using the Max(intKey) function and > >adding 1, because that would say that the next record will be 8 instead > >of 11. > > > >Is there something I am missing here? > > > >Thanks! > > > >Chris > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3171 Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
