[Zope] MySQL LAST_INSERT_ID...

raver@box.dust.za.net raver@box.dust.za.net
Wed, 17 Mar 1999 17:43:16 +0100


On Tue, Mar 16, 1999 at 02:49:43PM -0500, Tom Jenkins wrote:
> > > Error, exceptions.KeyError: unhandled 
> > > 
> > > SQL used:
> > > 
> > > select LAST_INSERT_ID()
> > > 
> > > Anybody have any ideas?
> > 
> > Why not use:
> > 
> > select 'id_field_name' from 'table' where 'id_field_name' IS NULL
> > 
> > id_field_name beeing the field with AUTO_INCREMENT set
> > 
> Hi Sture,
> Unfortunately, I don't think that'll work since after the insert there will be 
> a value (non null) in 'id_field_name'
> 
> Thanks for taking the time for a suggestion, I really do appreciate it.
>

Probly I misunderstod your problem.

Anyways I want to say that my suggestion does just what 'select
last_insert_id()' does. namely return the number created in an
auto_increment field during your last insert

Sture Lygren

> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Tom Jenkins                    DevIS (http://www.devis.com)
> Linux & Samba 2.0 : The best Windows file server
> http://www.zdnet.com/sr/stories/issue/0,4537,2196106,00.html                                         
> "Do not be overcome by evil, but overcome evil with good." Romans 12:21
>