Re: updating table field whenever other table field changes - Mailing list pgsql-general

From Jan Wieck
Subject Re: updating table field whenever other table field changes
Date
Msg-id 3E8CDFDF.2486DCDF@Yahoo.com
Whole thread Raw
In response to updating table field whenever other table field changes  (tech7890@yahoo.com (Andrew))
List pgsql-general
Andrew wrote:
>
> Hello postgresql.questions group!
>
> What do you think the best way to attack the following is:
> parent table a - [status_field]
>
> child table b - [status_field]
>
> I need trigger or similar to achieve the following:
> if a.status_field changes than all children of table a have their
> b.status_field change to the same value as a.

If b.status_field allways has to have a value that exists in
a.status_field (or maybe NULL if you allow it to), you want to define a
FOREIGN KEY constraint with the referential action ON UPDATE CASCADE.


Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #


pgsql-general by date:

Previous
From: Jan Wieck
Date:
Subject: Re: Anyone know of a news group for mysql?
Next
From: "Robert Fitzpatrick"
Date:
Subject: Converting from dbase