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() Anybody have any ideas? -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 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
On Mon, 15 Mar 1999, 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()
Anybody have any ideas?
Try: select LAST_INSERT_ID()+0 to cast it to an int... Also, check your declaration for LAST_INSERT_ID().. if the above doesn't work you'll need to either try the patch for ZMySQLDA that was posted a week or so ago, or do something like: SELECT CONCAT(LAST_INSERT_ID()) to cast it to a string and then use a nifty Python fn. to convert it to an integer number. It seems the MySQL driver has problems with some datatypes. There was a patch posted befure.. I'm curious to know if it'll fix this problem... ------- Jordan B. Baker -- jbb@spyderlab.com weaving the web @ http://www.spyderlab.com
OK to follow up, if you use call mysql using the form select CONCAT(LAST_INSERT_ID()) as new_id you get back the correct value in 'last_id' now I'm still having problems with getting that value into the REQUEST object. What goes in place of the ??? <!--#call REQUEST.set('last_id', ???)--> (Pardon me if this has been answered already, there was some problems with me getting messages from zope list) Thanks again...
On Mon, 15 Mar 1999, 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()
Anybody have any ideas?
Try: select LAST_INSERT_ID()+0 to cast it to an int...
Also, check your declaration for LAST_INSERT_ID().. if the above doesn't work you'll need to either try the patch for ZMySQLDA that was posted a week or so ago, or do something like: SELECT CONCAT(LAST_INSERT_ID()) to cast it to a string and then use a nifty Python fn. to convert it to an integer number.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 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
OK to follow up, if you use call mysql using the form select CONCAT(LAST_INSERT_ID()) as new_id you get back the correct value in 'last_id'
Umm that should read select CONCAT(LAST_INSERT_ID()) as last_id -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 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
On Tue, 16 Mar 1999, Tom Jenkins wrote:
OK to follow up, if you use call mysql using the form select CONCAT(LAST_INSERT_ID()) as new_id you get back the correct value in 'last_id'
now I'm still having problems with getting that value into the REQUEST object. What goes in place of the ??? <!--#call REQUEST.set('last_id', ???)-->
(Pardon me if this has been answered already, there was some problems with me getting messages from zope list) Thanks again...
Well, try something like: <!--#in lastInsert--> <li>The id last inserted is <!--#var new_id--> <!--#/in--> where lastInsert is your SQL method Note this is untested code, so caveat emptor :) Have fun, ------- Jordan B. Baker -- jbb@spyderlab.com weaving the web @ http://www.spyderlab.com
On Mon, Mar 15, 1999 at 11:17:44PM -0500, 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()
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 Hope this helps - Sture
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 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
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(For developer-specific issues, use the companion list, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Jordan B. Baker -
raver@box.dust.za.net -
Tom Jenkins