[Zope] ZSQL and last_insert_id

Jeff Peterson jpeterso@rangebroadband.com
Wed, 20 Feb 2002 09:34:46 -0600


Try: select <id> from <table> where <id> = last_insert_id()

I think that will work, if not you may try:

select <id> from <table> where <id> = conv(last_insert_id(), 10, 10)

Hope this helps,

--
Jeffrey D. Peterson
Webmaster & Resident Standards Warrior
"The Trouble with doing anything right the first time is that nobody
appreciates how difficult it was."


> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Chad
> Nantais
> Sent: Tuesday, February 19, 2002 5:04 PM
> To: zope@zope.org
> Subject: [Zope] ZSQL and last_insert_id
>
>
> What is the right syntax for getting the id of the last recorded inserted
> with ZSQL methods? I tried this:
> SELECT LAST_INSERT_ID() AS last_insert_id
>
> The resulting error is:
> Traceback (innermost last):
>   File /usr/local/zope/2.4.4b1/lib/python/ZPublisher/Publish.py, line 223,
> in publish_module
>   File /usr/local/zope/2.4.4b1/lib/python/ZPublisher/Publish.py, line 187,
> in publish
>   File /usr/local/zope/2.4.4b1/lib/python/Zope/__init__.py, line 226, in
> zpublisher_exception_hook
>     (Object: last_insert_id)
>   File /usr/local/zope/2.4.4b1/lib/python/ZPublisher/Publish.py, line 171,
> in publish
>   File /usr/local/zope/2.4.4b1/lib/python/ZPublisher/mapply.py,
> line 160, in
> mapply
>     (Object: manage_test)
>   File /usr/local/zope/2.4.4b1/lib/python/ZPublisher/Publish.py, line 112,
> in call_object
>     (Object: manage_test)
>   File /usr/local/zope/2.4.4b1/lib/python/Shared/DC/ZRDB/DA.py,
> line 400, in
> manage_test
>     (Object: last_insert_id)
>   File /usr/local/zope/2.4.4b1/lib/python/Shared/DC/ZRDB/DA.py,
> line 378, in
> manage_test
>     (Object: last_insert_id)
>   File /usr/local/zope/2.4.4b1/lib/python/Shared/DC/ZRDB/DA.py,
> line 493, in
> __call__
>     (Object: last_insert_id)
>   File /usr/local/zope/instance/Products/ZMySQLDA/db.py, line
> 252, in query
> OperationalError: (1064, "You have an error in your SQL syntax near
> 'last_insert_id LIMIT 1000' at line 1"
>
>
>
>
>
>
>
> _______________________________________________
> 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 )
>