I have tables representing a ledger system and the accounts on which it
operates.
I want to do 2 things to all transactions altering the ledger tables.
First, all of the inserts into the ledger tables should be balanced ( They
should sum to 0 ). If not I want to abort the transaction.
Second,
I do not know of a way to make your trigger run less often, but you could only
have it do the insert if something changes. This is what we do:
CREATE or replace FUNCTION UPDATE_SERVER_HST() RETURNS TRIGGER AS '
begin
if (OLD.ADD_DATE is distinct from NEW.ADD_DATE
or OLD.HOSTNAME
I am trying to make some foreign keys deferrable and initially deferred.
These foreign key constraints already exist so I was going to change them by
updating pg_trigger and pg_constraint.
However the changes do not seem to take affect. Is there something I need to
do to get PostgreSQL to rec
I am writing an update trigger that I want to fire when any field changes. It
looks like two ROWS can be compared very easily, but not the two RECORDS OLD
and NEW.
Is there a way to do:
NEW IS DISTINCT FROM OLD
in a trigger?
This would help me not have to write a specific trigger for each ta