[Zope] Multiple record input into Postgresql

Spicklemire, Jerry Jerry.Spicklemire@IFLYATA.COM
Thu, 10 Aug 2000 10:13:31 -0500


William wrote:

> inserts to a variable, say x1, into a postgresql table.  
> However, there is an additional variable, x2 that would 
> have to be only entered once and would be the same for 
> every record for which a different x1 is entered.  
> 
> it seems the <dtml-in> should do this.

Assign the variable x2.

	<dtml-call "REQUEST.set('x2',some_known_value)">

Create a list of all the x1 variables. This step could be 
a sql method, if the variables already exist in a table.

	<dtml-in sql_to_create_x1_list>
	</dtml-in>

Assign the value of sequence-item to variable this_x1.

	<dtml-call "REQUEST.set('this_x1',_['sequence-item'])">

Create a sql method to execute the inserts, and call it 
from within the first sql method, called using <dtml-in>.
Be sure to include "arguments" this_x1, x2.

	<dtml-var sql_insert_this_x1_x2>

So, altogether now:

<dtml-call "REQUEST.set('x2',some_known_value)">
<dtml-in sql_to_create_x1_list>
 <dtml-call "REQUEST.set('this_x1',_['sequence-item'])">
 <dtml-var sql_insert_this_x1_x2>
</dtml-in>

The <dtml-in> statement retrieves the cursor, calling the 
sql_insert for each item (sequence-item).