[Zope-DB] Batch update mode

Charlie Clark charlie at begeistert.org
Fri Aug 8 15:35:49 EDT 2003


On 2003-08-07 at 04:29:38 [+0200], Chan YH wrote:
> I phrased my question wrongly in my previous email and wished to thanks 
> those who replied.
> 
> I am trying to insert/update a table in a batch mode. The coding below is 
> a simplified version.
> 
> What I wanted to do is to INSERT/UPDATE a table (contact ) in a BATCH  
> mode. The user will see a form listing (company) and select the option 
> from  table (person).
> 
> Upon completion, the user a submit the matched listing to be inserted in 
> another table (contact).
> 
> I need some help  in doing this in a BATCH mode.
> 
> For e.g.  if I have 10 companies with the selected persons in a batch to 
> be inserted into contact table.
> 
>   Company name        Person
>   (company table)          (person table)
>  ----------------        --------
> 1. company A           Chan
> 2. company B           Henry
> ...
> 10. company X          Robert
> 
> insert/update batch to contact table.
> 
> Could someone give me some guidance?

I'm still not quite getting this but let's try and work something out.

You have two tables one with company names and one with people and you want 
to integrate this information in a single table? The first question has to 
be: does more than one person work for the same company? If the answer is 
yes then you will still need two tables and will link via a foreign key to 
avoid redundancy.

Regarding the HTML side of things: if we're assigning people to companies 
it probably makes sense to have the name and next to it a pull-down to 
select the company. The easiest way to program is to have one form per line 
with the actions repeated per line.

Something like

<form action="update" method="POST">
<input type="hidden" value="Henry Chan">
<tr>
<td>Henry Chan</td>
<td>
<select name="company">
<option value="company A">Company A</option>
</select>
</td>
<td><input type="submit" value="update"></td>
</tr>
</form>

Your script should then insert the data into the appropriate table (I'd 
suggest a new one for this) and then delete the user from the original 
table. It probably won't work directly like this because you should have 
IDs for the various data fields.

If you really want to batch (ie. process more than record at once) then you 
need to come up with some additional tagging information to distinguish 
between the various records. This is usually done by embedding a key in the 
various form field names TAL:repeat/number would be useful here.

Hope that helps

Charlie



More information about the Zope-DB mailing list