Re: Disabling Triggers

From: "Mark Borins" <mark(dot)borins(at)rigadev(dot)com>
To: "'Richard Huxton'" <dev(at)archonet(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Disabling Triggers
Date: 2005-05-11 16:12:34
Message-ID: 111582795401@smtp-1.vancouver.ipapp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

That looks like a good solution.
And that way it won't cascade.

Thanks

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Richard Huxton
Sent: May 11, 2005 11:53 AM
To: Mark Borins
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Disabling Triggers

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

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2005-05-11 16:16:19 Re: Disabling Triggers
Previous Message Tom Lane 2005-05-11 16:07:43 Re: JOIN on set of rows?