Or, use a stored procedure that returns the identity.
-- Avrom
At 12:21 AM 3/20/2001 -0500, you wrote:
>ok .. then try two seperate queries and wrap them both in a <cftransaction>
>to single-thread them. That should get you what you are after. Like so:
>
><cftransaction action="BEGIN">
> <cfquery name="name1" datasource="gunledger" dbtype="ODBC">
> INSERT INTO dbo.distrib(compname, phonenum, address, address2, city,
>state, zip, fflid, expires)
> VALUES('#compname#', '#phonenum#', '#address#', '#address2#',
>'#city#', '#state#', '#zip#', '#fflid#', '#expires#')
> </cfquery>
>
> <cfquery name="name2" datasource="gunledger" dbtype="ODBC">
> SELECT @@identity as identity
> </cfquery>
></cftransaction>
>
>Then reference the value as name2.identity
>
>I don't know if the single quotes around the 'identity' in your query
>matter, but in my experience, they aren't needed.
>
>Todd Ashworth
>Web Application Developer
>Network Administrator
>
>Saber Corporation
>314 Oakland Ave.
>Rock Hill, SC 29730
>(803) 327-0137 [111] (p)
>(803) 328-2868 (f)
>
>----- Original Message -----
>From: "Joshua Tipton" <[EMAIL PROTECTED]>
>To: "CF-Talk" <[EMAIL PROTECTED]>
>Sent: Tuesday, March 20, 2001 12:06 AM
>Subject: RE: @@identity
>
>
> > When I do that CF says not a valid query specified.
> >
> > -----Original Message-----
> > From: CF [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, March 20, 2001 12:04 AM
> > To: CF-Talk
> > Subject: Re: @@identity
> >
> >
> > You need to give your query a name. Instead <cfquery name="", use
><cfquery
> > name="queryName". Then you just access that variable as:
> >
> > queryName.identity
> >
> > Also, I don't know it it matters to your database or not, but you might
>want
> > to put a ; at the end of your first query to differentiate it from the
>next
> > .... just to avoid confusion.
> >
> > Todd Ashworth
> > Web Application Developer
> > Network Administrator
> >
> > Saber Corporation
> > 314 Oakland Ave.
> > Rock Hill, SC 29730
> > (803) 327-0137 [111] (p)
> > (803) 328-2868 (f)
> >
> > ----- Original Message -----
> > From: "Joshua Tipton" <[EMAIL PROTECTED]>
> > To: "CF-Talk" <[EMAIL PROTECTED]>
> > Sent: Monday, March 19, 2001 11:32 PM
> > Subject: @@identity
> >
> >
> > > I know how to use @@identity to select the last inserted record right
> > under
> > > an insert but how do I display that id of that record?
> > >
> > > <cfquery name="" datasource="gunledger" dbtype="ODBC">
> > > INSERT INTO dbo.distrib(compname, phonenum, address, address2, city,
> > state,
> > > zip, fflid, expires)
> > > VALUES('#compname#', '#phonenum#', '#address#', '#address2#', '#city#',
> > > '#state#', '#zip#', '#fflid#', '#expires#')
> > > select @@identity as 'identity'
> > > </cfquery>
> > >
> > > How do I output the identity????
> > >
> > > Josh
> > >
> > >
> > >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists