From: | Tino Wildenhain <tino(at)wildenhain(dot)de> |
---|---|
To: | Luuk Jansen <subscribe(at)angelosystems(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Updating in multiple tables |
Date: | 2006-03-20 14:34:30 |
Message-ID: | 441EBD76.7060004@wildenhain.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Luuk Jansen schrieb:
> I have a quick newbee question:
>
> Is is possible to update in multiple tables at the same time.
> I am working with PHP scripts and will use the following example to
> explain what I want to do:
>
> I have a generic_user tables, which forms a INNER JOIN with the
> logon_user table (with a join using id).
>
> generic_user:
> - id
> - name
> - passowrd
>
> logon_user:
> - id
> - last_logon
> - nickname
>
> As I load all the fields at once in an array, and want to update the
> same, so just something like
>
> "UPDATE generic_user INNER JOIN logon_user USING (id) SET name='test',
> nickname='test2' WHERE id = 1";
>
> Is there anybody who can explain how to do this?
You either update both tables in subsequent update statements
(in one exec call or inside your transaction)
or create an updateable view.
(Just like aregular view and then add a rule for update - maybe
using a call to a stored function)
or just use the stored function directly.
HTH
Tino
From | Date | Subject | |
---|---|---|---|
Next Message | Linda | 2006-03-20 14:44:38 | Re: question about postgresql time intervals |
Previous Message | Ian Harding | 2006-03-20 14:31:31 | Re: Wal -long transaction |