If the PK is an incrementing numeric value, your second query could be
simplified with the max() function

<CFQUERY>
select Max(tableID) AS MaxTableID from table
</CFQUERY>

You would call it as #Queryname.MaxTableID#

Also, you can find a Custom Tag that does this automagically at
www.fusebox.org

-Cameron

> -----Original Message-----
> From: Jeffry Houser [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, January 28, 2001 8:10 PM
> To: CF-Talk
> Subject: Re: Finding last record
>
>
>
>  I'm jumping into this thread late, so excuse me if this is way off base.
>  We could use CFTRANSACTION to prevent other users from inserting
> another record.
>
>   As the original had requested, this is not an uncommon way to do it:
>
>    <CFTRANSACTION>
>
>        <CFQUERY>
>          Insert into table () values ()
>        </CFQUERY>
>
>         <CFQUERY>
>            select tableID from table where values = values
>          </CFQUERY>
>
>       </CFTRANSACTION>
>
>   The second query will contain the ID of the data we just entered.
>
>
> Laszlo Nadai wrote:
>
> > And what would guarantee, that there was not another user, who just
> > inserted another record?
> > laszlo
> >
> > William J Wheatley wrote:
> > >
> > > you could have it Select only 1 RECORD and order by the
> Primary Key field
> > > and then you should get the last record that way.
> > >
> > > Bill Wheatley
> > > Director of Development
> > > Allaire Certified ColdFusion Developer
> > > AEPS INC
> > > Allaire ColdFusion Consulting Partner
> > > www.aeps.com
> > > www.aeps2000.com
> > > 954-472-6684 X303
> > > ICQ: 417645
> > >
> > > ----- Original Message -----
> > > From: "Chad Elley" <[EMAIL PROTECTED]>
> > > To: "CF-Talk" <[EMAIL PROTECTED]>
> > > Sent: Sunday, January 28, 2001 7:10 AM
> > > Subject: Finding last record
> > >
> > > > I am inserting a record into one of my tables in MS Access.
>  I want to
> > > then
> > > > find the primary key(auto number) immediately after
> insertion.  Is there
> > > an
> > > > easy way to find it?
> > > >
> > > > Thanks,
> > > > Chad
> > > >
> > > >
> > > >
> > >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to