[Zope] ZMySQLDA and ZSQLMethods

Phil Harris phil at harris-family.info
Tue Oct 28 15:51:45 EST 2003


Andrew,

Think what this query actually does:

SELECT LAST_INSERT_ID() as id from cc_transactions

It does a select last_insert_id() for every row in cc_transactions.

therefore, you should get a list of ids.

I presume you really wanted,

select last_insert_id() as an_id





Andrew Altepeter wrote:

>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.  However, I get a list of id:integers with every
>id=actual last_insert_id, and a length equal to the number of rows in
>the table.
>
>I haven't been able to recreate this behavior in a mysql shell client.
>
>Any ideas about what's going on?
>
>my mysql version is: 3.23.58
>
>Thanks,
>Andy
>
>
>_______________________________________________
>Zope maillist  -  Zope at zope.org
>http://mail.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists - 
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>  
>




More information about the Zope mailing list