Re: [Zope] dtml Z SQL doubt
On Thu, Mar 22, 2007 at 08:11:21AM -0400, Allen Schmidt Sr. wrote: > Just use REPLACE instead of INSERT. > If REPLACE statement is able to determine a unique value for a row and > sees that that unique value exists for a row, the valued will be > updated. If it does not exist, a new row will be inserted. This is what > I use with MySQL. Or, depending on what you want, the INSERT...ON DUPLICATE KEY UPDATE syntax can be used. http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html Note that both of these idioms are specific to MySQL and not portable to other databases. -PW -- Paul Winkler http://www.slinkp.com ___ Zope maillist - Zope@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 )
Re: [Zope] dtml Z SQL doubt
Just use REPLACE instead of INSERT. If REPLACE statement is able to determine a unique value for a row and sees that that unique value exists for a row, the valued will be updated. If it does not exist, a new row will be inserted. This is what I use with MySQL. Allen Tino Wildenhain wrote: Remil Mathew schrieb: Hi all, I need to insert a row to mysql table if the corresponding data not exist, if it exist i need to update the row. Can we do it using a single Z SQL method. Well thats not business of ZSQL methods but rather stuff you do with the instruments of your database. Say SQL (or whatever SQL like mysql has there) IIRC, mysql has some kind of UPSERT which should handle it. If not, stored procedure or trigger etc could do it. Regards Tino ___ Zope maillist - Zope@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 ) ___ Zope maillist - Zope@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 )
Re: [Zope] dtml Z SQL doubt
Remil Mathew schrieb: Hi all, I need to insert a row to mysql table if the corresponding data not exist, if it exist i need to update the row. Can we do it using a single Z SQL method. Well thats not business of ZSQL methods but rather stuff you do with the instruments of your database. Say SQL (or whatever SQL like mysql has there) IIRC, mysql has some kind of UPSERT which should handle it. If not, stored procedure or trigger etc could do it. Regards Tino ___ Zope maillist - Zope@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 )
Re: [Zope] dtml Z SQL doubt
> Hi all, > > I need to insert a row to mysql table if the corresponding data not > exist, if it exist i need to update the row. > > Can we do it using a single Z SQL method. Yes, if your ZSQL will call stored procedure that will handle this logic. Otherwise, I think you can't (but I might be wrong). -- Maciej Wisniowski ___ Zope maillist - Zope@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 )
[Zope] dtml Z SQL doubt
Hi all, I need to insert a row to mysql table if the corresponding data not exist, if it exist i need to update the row. Can we do it using a single Z SQL method. Many thanks Anz ___ Zope maillist - Zope@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 )