[Zope-DB] MASTER/DETAIL - inserting a variable number of rows

Richard Rosenberg richrosenberg at earthlink.net
Thu Aug 26 18:48:40 EDT 2004


Being relatively new to Zope, I have what I hope is a simple question.  
What would be the recommended solution for the following:

1. I have two tables, TABLE_MASTER, and TABLE_DETAIL.
2. For each row in TABLE_MASTER there is at least 1 row in TABLE_DETAIL
3. I want to insert 1 row in TABLE_MASTER and insert a variable number  
of rows into TABLE_DETAIL in a single transaction. That is, if the  
insert into TABLE_MASTER, or any of the potentially multiple inserts  
into TABLE_DETAIL fail, the entire transaction is rolled back and no  
insertion takes place in either table.

My questions is:

Can this be done with a single zsql method, or with zsql at all?

It seems like there should be a way to pass lists as the parameters and  
have some sort of <dtml-in . . .> to iterate an insert statement for  
each item in the passed list(s). In combination with  My intention is  
to call this zsql from a python class method that is part of a product  
I am messing around with/creating.

Thanks for any info,

Richard



More information about the Zope-DB mailing list