[Zope] Bulk insert in Zope's ZPyGres

Phillip J. Eby pje@telecommunity.com
Thu, 22 Jul 1999 07:20:55 -0500


At 10:37 AM 7/22/99 +0000, Paul Chung Chee Soong wrote:
>Thanks. But how do use insert statements thru Z SQL Mtehod submitting it   
>again? We will need to submit the web page a lot of times to get the   
>variables across, wouldn't we? How do we address this problem ?


As I said before, just make the checkbox field a :list field, and have your
SQL method do an <!--#in--> block that loops over it to create a series of
INSERT statements in one batch.

For example, if your checkbox field is called "item_to_borrow:list".  Your
SQL method would look something like:

<!--#in item_to_borrow-->
INSERT INTO my_table (the_item) VALUES (<!--#var sequence-item-->)
<!--#/in-->

Obviously, you would need to change this to suit the values you actually
need to insert.  The above will generate a series of INSERT statements in a
single batch, one for each checked item.  When the SQL method runs, it will
send all the INSERT's to the database at once.