James, in which cases is it not 100% reliable? Are the CF-Talk archives
searchable?

Ryan, your method seems ideal... but I think it would take me a month to do
it... what DB datatype is your UUID?

Cheers,
Baz


-----Original Message-----
From: Ryan Guill [mailto:[EMAIL PROTECTED] 
Sent: Sunday, January 08, 2006 8:08 PM
To: CF-Talk
Subject: Re: Get last inserted ID

What I usually do is have a column that just holds a specific
timestamp or uuid of some sorts.  I create a variable to hold the
timestamp or uuid right before the insert query, then I select against
the table looking for that timestamp or uuid.  If you are using a db
that stores a pretty detailed timestamp, especially down to the
millisecond (not sure how mysql does it), that would work very well. 
And if you can use a uuid for the primary key instead of an
autonumber, then you will have the id before you enven to the insert
statement.

Just some ideas.
On 1/8/06, James Holmes <[EMAIL PROTECTED]> wrote:
> It's only 100% reliable if you use a serializable transaction, as far
> as I remember. This is certainly the case with Oracle.
>
> There is an extensive thread on this in the archives somewhere.
>
> On 1/9/06, Baz <[EMAIL PROTECTED]> wrote:
> > Is this the best way to do this:
> >
> > <cftransaction>
> >   <cfquery name="InsertAddress" datasource="#DSN#">
> >     INSERT INTO Address (City)
> >     VALUES (<cfqueryparam value="#City#" cfsqltype="cf_sql_integer" />)
> >   </cfquery>
> >
> >   <cfquery name="getInsertedID" datasource="#DSN#">
> >     SELECT MAX(AddressID) as MaxID
> >     FROM Address
> >   </cfquery>
> > </cftransaction>
> >
> > I'm using MySQL.
>
> --
> CFAJAX docs and other useful articles:
> http://jr-holmes.coldfusionjournal.com/
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:228790
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to