[Zope-DB] Re: How do you do update with multiple tables

Sean Fulmer seanmeister1 at netzero.com
Fri Apr 30 15:58:03 EDT 2004


Laura McCord wrote:
> First of all, I am passing an argument 'pcname'.
> 
> I have two tables that are linked by pcname
> 
> Table Users        Table pcTable
> 
> userid                 pcid
> username     |-------- pcname
> useremail    |         pcmake
> useroffice   |         pcmodel
> userpwd      |         pcserial
> pcname--------         
> 
> 
> If I want to update the pcname in the pcTable then I want the pcname in
> the users table to update as well. How is this done? This is what I have
> so far:
> 
> update pcTable ,users
> set
> pcTable.pcname = '<dtml-var name="pcname" sql_quote>',
> pcTable.pcmake = '<dtml-var name="pcmake" sql_quote>',
> pcTable.pcmodel = '<dtml-var name="pcmodel" sql_quote>',
> pcTable.pcserial = '<dtml-var name="pcserial" sql_quote>',
> pcTable.pcmhz = '<dtml-var name="pcmhz" sql_quote>',
> pcTable.pcmbram = '<dtml-var name="pcmbram" sql_quote>',
> pcTable.pc_oem_os = '<dtml-var name="pc_oem_os" sql_quote>',
> pcTable.pc_oem_os_key = '<dtml-var name="pc_oem_os_key" sql_quote>',
> pcTable.pc_ip_add = '<dtml-var name="pc_ip_add" sql_quote>',
> users.pcTable = '<dtml-var name="pcname" sql_quote>'
> where
> pcname = '<dtml-var name="pcname" sql_quote>'
> 
> Is there something that I am forgetting?
> 
> Thanks,
>  Laura

Hard to tell what you're forgetting if you don't say what kind of 
problem you're having (ie a detailed error message)

IMO, the correct thing to do would be add a pcid field to your user 
table. If you join your tables on pcid, then you only need to change 
pcname in one place.

-- 
Sean F




More information about the Zope-DB mailing list