Re: Disabling Triggers

From: Richard Huxton <dev(at)archonet(dot)com>
To: Mark Borins <mark(dot)borins(at)rigadev(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Disabling Triggers
Date: 2005-05-11 15:53:15
Message-ID: 42822A6B.5020404@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mark Borins wrote:
> I am creating a system where I have a trigger on three different tables.
> There is a particular Boolean field in each of these tables that when it is
> set in table it should be set the same in the other two.

Just make sure you only check the boolean value too:

-- Trigger on table a does:
IF NEW.my_bool=OLD.my_bool THEN
RETURN NEW;
END IF;

UPDATE b SET my_bool=NEW.my_bool
WHERE id=NEW.something AND my_bool <> NEW.my_bool
UPDATE c SET my_bool=NEW.my_bool
WHERE id=NEW.something AND my_bool <> NEW.my_bool
-- End code

That way, you always do the minimal amount of work anyway.
--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-05-11 16:04:14 Re: alter table owner doesn't update acl information
Previous Message Richard Huxton 2005-05-11 15:47:47 Re: JOIN on set of rows?