[Zope] MySQL LAST_INSERT_ID...

Rob Page rob.page@digicool.com
Tue, 16 Mar 1999 10:57:04 -0500


Tom:

[Reading from my support script..]
This is where I say, "Hmm, I'm no expert on MySQL...." ;^) Anyone else
have any ideas?  This, um, worked on Sybase!?

--Rob

Tom Jenkins wrote: 
> > >  To followup my last post, I'm getting an exception when 
> > >  trying to use 
> > >  MySQL's  "select LAST_INSERT_ID()" function:
> > >  
> > >  Error, exceptions.KeyError: unhandled 
> > >  
> > >  SQL used:
> > >  
> > >  select LAST_INSERT_ID()

Rob Page replied:
>  >Try:
>  > 
>  > select LAST_INSERT_ID() as fred
>  > 
>  > then grab <!--#var fred-->
>  > 
>  > If this works then I know what the problem is!  :^)
>  > 
>  > If you use the database's command line tool and run this 
>  SQL statement I
>  > bet it returns a single value (i.e., it doesn't return a 
>  table).  The DA
>  > wants to munge and chew on rows in tables.  If think that 
>  if you use the
>  > select LAST_INSERT_ID() as fred you'll get a one-row, 
>  one-column table
>  > -- this is what Zope wants.

Then Tom wrote back:
>  Hi Rob,
>  Made the change and tested but still got the exception.
>  I ran it at the command line (for mysql) and it returns a 
>  "table" with one 
>  row and field