Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA97700 for ; Tue, 4 Jan 2000 10:55:21 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id KAA13261; Tue, 4 Jan 2000 10:55:11 -0500 (EST) To: "Mitch Vincent" cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Triggers In-reply-to: <00cc01bf56c5$03cd5e80$40ee2fd8@venux.net> References: <21582.943985242@sss.pgh.pa.us> <00cc01bf56c5$03cd5e80$40ee2fd8@venux.net> Comments: In-reply-to "Mitch Vincent" message dated "Tue, 04 Jan 2000 10:04:35 -0500" Date: Tue, 04 Jan 2000 10:55:11 -0500 Message-ID: <13258.947001311@sss.pgh.pa.us> From: Tom Lane "Mitch Vincent" 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