From: | "Mitch Vincent" <mitch(at)venux(dot)net> |
---|---|
To: | <pgsql-sql(at)postgreSQL(dot)org> |
Subject: | Triggers |
Date: | 2000-01-04 15:04:35 |
Message-ID: | 00cc01bf56c5$03cd5e80$40ee2fd8@venux.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I'm using this funtion via a trigger to total up amounts in several fields
(and adding that value into a total field)..
CREATE FUNCTION invoice_total_trigger() RETURNS OPAQUE AS '
BEGIN
NEW.total := NEW.fee_membership + NEW.fee_logins + NEW.fee_convention +
NEW.fee_prints+ NEW.fee_hotlines + NEW.fee_postage + NEW.fee_ups +
NEW.fee_late + NEW.fee_other1 + NEW.fee_other2 + NEW.fee_other3 +
NEW.fee_pastdue;
RETURN NEW;
END;
' LANGUAGE 'plpgsql';
That's the function, here is the trigger.
CREATE TRIGGER invoice_total_trigger AFTER INSERT OR UPDATE ON invoice
FOR EACH ROW EXECUTE PROCEDURE invoice_total_trigger();
It works for updating but not when you insert a new row. Am I doing it
wrong?
I need the invoice_total_trigger to run every time a row is updated or
inserted..
Thanks guys!
-Mitch
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-01-04 15:55:11 | Re: [SQL] Triggers |
Previous Message | Bruce Momjian | 2000-01-03 17:20:18 | Re: [ADMIN] restriction clause selectivity bad valueu |