[Zope] ZSQL method LAST_INSERT_ID() error
Arno Gross
arno.gross@consotec.de
Wed, 14 Mar 2001 07:03:44 -0100
Search in the mail archive for LAST_INSERT_ID().
What did your LAST_INSERT_ID statement return?
I had the problem that I get an exception error which I could
solve with Dieters hint:
SELECT CONV(LAST_INSERT_ID(),10,10) as TheLastId
An alternative can be to use:
SELECT MAX(<yourAutoIncrementAttr>)
Best regards
Arno
On Tue, 13 Mar 2001, paul_s_johnson@urscorp.com wrote:
> Thanks for the all tips; it's getting me down the right road.
>
> I also learned I need to include my LAST_INSERT_ID in the same ZSQL method
> as my INSERT statement and join them together with a <dtml-var
> sql_delimiter> inside the method.
>
> That said, it's still not working. Here's what's returned when I test my
> method:
>
> There was no data matching this sql_add_deliverable query. SQL used:
> INSERT INTO Deliverables (
> DeliverableID,
> ProjectID,
> DeliverableTypeID,
> UserID,
> Abstract,
> DateEntered,
> CategoryRequest)
> VALUES (
> NULL,
> 1,
> 2,
> 3,
> 'some text blah blah',
> NOW(),
> '5')
>
> ------------------------------------------------------------
>
> SELECT LAST_INSERT_ID() AS TheLastID
>
>
> The INSERT part of the above works and inserts the data into the table. The
> DeliverableID field of the Deliverables table is really an AUTO_INCREMENT
> field. I tested the above at the MySQL command line and the LAST_INSERT_ID
> () function returns the correct ID. Why is no data returned? I should be
> getting the last ID and I'm getting nothing. Help!
>
> P. Johnson
>
>
>
>
> http://www.zope.org/Members/adustman/Tips/no_limits
>
> On Tue, 13 Mar 2001 paul_s_johnson@urscorp.com wrote:
>
> > This ZSQL query:
> >
> > SELECT LAST_INSERT_ID() AS ID
> >
> > Is returning this error:
> >
> > Error, _mysql.OperationalError: (1064, "You have an error in your
> SQL
> > syntax near 'LIMIT 1000' at line 1")
> >
> > It apparently automatically adds a LIMIT clause to the end of my SQL
> query
> > that MySQL does not like in this context. Is there any way to shut the
> > limit clause off? Anybody have any ideas for a workaround?
>
> --
> Andy Dustman PGP: 0xC72F3F1D
> @ .net http://dustman.net/andy
> "Normally with carbonara you use eggs, but I used lobster brains instead."
> -- Masahiko Kobe (Iron Chef Italian): 30-year-old Giant Lobster Battle
>
>
>
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )