Yes...if it's to get the ID just added....if that's the case...here's some decent examples for Access/Oracle/MS SQL Server:
http://www.webtricks.com/sourcecode/code.cfm?CodeID=23 Cheers Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. t. 250.920.8830 e. [EMAIL PROTECTED] --------------------------------------------------------- Macromedia Associate Partner www.macromedia.com --------------------------------------------------------- Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com ----- Original Message ----- From: "Scott Weikert" <[EMAIL PROTECTED]> To: "SQL" <[EMAIL PROTECTED]> Sent: Monday, September 15, 2003 1:15 PM Subject: Re: insert/select > At 04:07 PM 9/15/2003 -0400, you wrote: > >Is there a way of doing an insert and a select on the data that was just > >inserted as a single operation inside a CFQUERY tag? Not in an SP, but as > >straight SQL. > >If not, I'll have to do the transaction, insert, select thing. I'm just > >looking > >for the best option. > > I know you can extract the newly created identity ID field value... > > <cfquery name="yourinsertqueryname"> > set nocount on > (your insert query) > select NewID (or whatever var you want) = @@IDENTITY > set nocount off > </cfquery> > > then you can get that ID as #yourinsertqueryname.NewID#. > > As far as the rest of the data, chances are you could get at it the same > way, but instead of @@IDENTITY, use the fieldname... not sure if you'd need > any sort of code-like chars in front though. > > Aside from the identity field, you're doing a straight INSERT so you should > already have the rest of the data handy, should you not? > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:6 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:6 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=<:emailid:>.<:userid:>.<:listid:> Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
