Andrew G,

But...:)

A single request won't necessarily keep the same connection, especially
under load.  So unless you use a transaction, it's entirely possible for the
insert query to run on one connection, and the select last_insert_id() to
run on another connection. See http://lagod.id.au/blog/?p=41
Jaime
On Tue, Dec 8, 2009 at 8:51 AM, Andrew Grosset <rushg...@yahoo.com> wrote:

>
> maybe not (wrong)...
>
> The ID that was generated is maintained in the server on a per-connection
> basis. This means that the value returned by the function to a given client
> is the first AUTO_INCREMENT value generated for most recent statement
> affecting an AUTO_INCREMENT column by that client. This value cannot be
> affected by other clients, even if they generate AUTO_INCREMENT values of
> their own. This behavior ensures that each client can retrieve its own ID
> without concern for the activity of other clients, and without the need for
> locks or transactions.
>
>
> http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id
>
> > > I was under the impression that Last_Insert_ID() in MySQL was the
> > equilavent of Scope_Identity() in MSSQL.....please correct me
> > > if I'm wrong.
> >
> > You're wrong, I think. From the MySQL docs:
> >
> > "For LAST_INSERT_ID(), the most recently generated ID is maintained
> > in
> > the server on a per-connection basis."
> >
> > If two page requests are running simultaneously, they're not using
> > the
> > same connection.
> >
> > Dave Watts, CTO, Fig Leaf Software
> > http://www.figleaf.com/
> >
> > Fig Leaf Software provides the highest caliber vendor-authorized
> > instruction at our training centers in Washington DC, Atlanta,
> > Chicago, Baltimore, Northern Virginia, or on-site at your location.
> > Visit http://training.figleaf.com/ for more
> information!
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328934
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to