Search Postgresql Archives

Re: Disabling Triggers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux