[Zope] ZSQL retreive auto_increment id inserted [Q]

Sam Gendler sgendler@teknolojix.com
Tue, 16 Nov 1999 19:39:49 -0800


chas wrote:

> Re: getting auto_insert_id() from MySQLDA :
>
> The problem lies in the last few lines of db.py -
> the variable 'desc' does not contain the correct values
> for many SQL queries (the last_insert_id() is just one
> of them; several complex queries including aliases and
> 'group by' also fail)
>
> Kludge
> ------
> (warning : ain't pretty - I just needed to get this working now) :
>

<snip>

I didn't take a long look, but it looks as though this solution requires
you to call a separate ZSQL query in order to retrieve the ID.  Needless to
say, there is a wide open race condition if someone else inserts another
entry before you get the results from the second query. I was looking for
something that returns the last_insert_id as the result set to an INSERT
query, much the way the apis (for mysql anyway) do in other environments.
Please correct me if I am wrong.  Thanks for the effort, anyway


--sam