[Zope] ZMySQLDA and ZSQLMethods

Dieter Maurer dieter at handshake.de
Tue Oct 28 15:45:11 EST 2003


Andrew Altepeter wrote at 2003-10-28 08:40 -0600:
 > I have a zsql method that inserts data into a table with an
 > auto_increment column, and then calls select last_insert_id():
 > ----------------------
 > INSERT INTO cc_transactions(acct,who,total,creationtime)
 >   VALUES(<dtml-sqlvar account type="string">,
 >          <dtml-sqlvar who type="string">,
 >          <dtml-sqlvar total type="float">,
 >          NOW())
 > <dtml-var sql_delimiter>
 > SELECT LAST_INSERT_ID() as id from cc_transactions
 > ----------------------
 > 
 > One would expect to get just one integer (well, id:integer) back from
 > calling this method.

Any "select" returns an instance that behaves like a sequence.
It never returns an integer.

Thus, you should be able to access the id by "result[0].id" (when
"result" is the result of your Z SQL Method).

-- 
Dieter



More information about the Zope mailing list