AutoNumbers and INSERTS
Hi, I'm inserting a load of data into a Table of an Access Database. The ID field is generated by AutoNumber. As soon as the record has been inserted, I need to output what that ID was. How can I do this? Cheers Will... -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: AutoNumbers and INSERTS
- Original Message - From: "Homer Simpson" [EMAIL PROTECTED] Newsgroups: cf-talk Sent: Friday, September 29, 2000 1:38 PM Subject: RE: AutoNumbers and INSERTS You could try adding the data with a CFQUERY INSER and then immediately after do a CFQUERY SELECT ID FROM My_Table WHERE blah = whatwasjustadded AND blah2 = whatwasalsoadded /CFQUERY including as much info as possible so that you only get one record returned and then output the ID as you would normally Yeah, that's what I thought - it just seemed a bit messy doing it that way :o) Cheers Will -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: AutoNumbers and INSERTS
Hi Will, There are two real possibilities: 1) stick with autonumbering. Wrap your insert and a SELECT Max(ID) inside a single CFTRANSACTION. Vaguely ugly. 2) Create your own Primary Key. 2a) Create your own incremental ID from a separate table. Needs CFTANSACTION. 2b) Create an incremental key by first selecting the current Max ID. (see the FuseBox tag MaxID for this) Needs CFTRANSACTION. 2c) Create your own random key. Use CF's built-in uuid function, or make your own with randrange, dates, etc, in combination. Excellent if you deal with several replicas which are merged from time to time. Personally, I use CF_MaxID and CFTRANSACTION. Best of luck, Lee Bjork Borkman Bjork.Net - ColdFusion Tags by Bjork "W Luke" [EMAIL PROTECTED] wrote: Hi, I'm inserting a load of data into a Table of an Access Database. The ID field is generated by AutoNumber. As soon as the record has been inserted, I need to output what that ID was. How can I do this? Cheers Will... -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. Get free email and a permanent address at http://www.netaddress.com/?N=1 -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebarRstsbodyRsts/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: AutoNumbers and INSERTS
this is one way... there are many others... cftransaction (first query) cfquery name="getmax" datasource="#session.dsn#" SELET max (id_column_name) as maxid FROM tablename /cfquery /cftransaction -- Mark Warrick Phone: (714) 547-5386 Efax.com Fax: (801) 730-7289 Personal Email: [EMAIL PROTECTED] Personal URL: http://www.warrick.net Business Email: [EMAIL PROTECTED] Business URL: http://www.fusioneers.com ICQ: 346566 -- -Original Message- From: W Luke [mailto:[EMAIL PROTECTED]] Sent: Friday, September 29, 2000 5:00 AM To: CF-Talk Subject: AutoNumbers and INSERTS Hi, I'm inserting a load of data into a Table of an Access Database. The ID field is generated by AutoNumber. As soon as the record has been inserted, I need to output what that ID was. How can I do this? Cheers Will... -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf _talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body. -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebarRstsbodyRsts/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.