[Zope] multiple records update
Tino Wildenhain
tino at wildenhain.de
Tue Oct 14 15:14:33 EDT 2003
Hi Mike,
Mike Doanh Tran wrote:
> Howdy,
>
> I am trying to update multiple customers records on the same page. I put
> individual customer records into lists. For example, I have four lists:
>
> field1: ['a','b','c','d'}
> field2: ['a2','b2','c2','d2']
> field3: ['a3','b3','c3','d3']
> Cust_ID: ['1','2','3','4']
First, just let Zope help you:
name your form variables like that:
<input type= ... name="cust.field1:records" >
cust.field2:records
cust.field3:records
cust.Cust_ID:records
Now you get a list with the name "cust"
where each list entry is a dictionary with the
keys field1, field2, field3 and Cust_ID.
(See Zope Book for documentation on this)
>
> How do i break these list down so that i can pass it to a ZSQL method to
> udpate this:
>
> UPDATE customers SET
> field1=a,
> field2=a2,
> field3=a3,
> where Cust_ID=1
>
> Then interate until the end of each list where Cust_ID=4
>
> Is this possible to do in DTML? Thanks in advance for any suggestions,
>
> Mike
IF you want to call the ZSQL method several times, you better do it
in a python script.
If the list is not long and your database/adaptor supports
multiple update statements in one query, you _could_ use
<dtml-in cust mapping>
UPDATE customers SET field1=<dtml-sqlvar field1 type=string> ...
WHERE Cust_ID=<dtml-sqlvar Cust_ID type=int>;
</dtml-in>
I think you get the picture now.
Regards
Tino
More information about the Zope
mailing list