Re: [SQL] Triggers - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] Triggers
Date
Msg-id 13258.947001311@sss.pgh.pa.us
Whole thread Raw
In response to Triggers  ("Mitch Vincent" <mitch@venux.net>)
List pgsql-sql
"Mitch Vincent" <mitch@venux.net> writes:
> I'm using this funtion via a trigger to total up amounts in several fields
> (and adding that value into a total field)..

> 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?

Er, don't you want BEFORE INSERT OR UPDATE?

I wouldn't think an AFTER trigger could modify the already-inserted-or-
updated row...
        regards, tom lane


pgsql-sql by date:

Previous
From: "Mitch Vincent"
Date:
Subject: Triggers
Next
From: "Mitch Vincent"
Date:
Subject: Re: [SQL] Triggers