Bruce and Steven,

I hate to quibble, but there are some issues with this
psuedo-code that I think should be pointed out.

1) The use of the application.dsn variable:  if you use
this variable, you will need to wrap the entire query with
a CFLOCK inorder to lock the application scope for readonly 
access.  I would suggest you duplicate the application scope
into the request scope and access request.dsn, which eliminates
the need to CFLOCK.  See the recent summary on this issue for
more information.

2) CFTRANSACTION: The first two queries need to be wrapped with
a CFTRANSACTION tag.  By doing to you ensure that CF is getting
the correct ID since no other writes to the table can occur within
the CFTRANSACTION block.  Without it, there is the possbility
(however remote) that another user wrote to the database between
these two queries and when you extract the Max ID, you are getting
that record and not the one you really want.

Good luck,
Beau


-----Original Message-----
From: Bruce Sorge [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 12, 2001 5:12 PM
To: CF-Talk
Subject: Re: Trying to access information I just inserted in Access


I usually do this (Presuming that you are using AutoNumbering).

<cfquery datasource=#Application.DSN#>
 INSERT INTO.....
</cfquery>

<cfquery datasource=#Application.DSN# Name="qSomeName">
 Select MAX(Some_ID) AS LastID
 From Sometable
</cfquery>

<cfquery datasource=#Application.DSN# Name="qWhatever">
 Select Something
 From Somewhere
 Where ID = #qSomeName.ID#
</cfquery>

---------- Original Message ----------------------------------
From: Steven  Lancaster <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Date:  Mon, 12 Nov 2001 15:51:27 -0600

>I have a form which inserts data into an access database. Once that
data is
>inserted I need to access the ID for that data so that I can send a URL
in
>an email for them to click on so that the information can be updated by
>somebody else. I am running into the problem once I insert it tells me
it
>does not understand #id#. I do a query right after the insertion so
that it
>can pull that info, but how do I cross reference?
>
> Steven Lancaster
> WebMaster
> Core Laboratories
> 6316 Windfern
> Houston, TX 77040
> 713-328-2532 (Office)
> 713-328-2150 (Fax)
> 832-259-3010 (Cell)
> mailto:[EMAIL PROTECTED]
>
> http://www.corelab.com
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to