Received: from redbox.venux.net (redbox.venux.net [216.47.238.10]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA61765 for ; Tue, 4 Jan 2000 14:28:18 -0500 (EST) (envelope-from matthew@venux.net) Received: from thunder (net4842.hcv.com [216.93.48.42]) by redbox.venux.net (Postfix) with ESMTP id E0A102E20B; Tue, 4 Jan 2000 14:21:23 -0500 (EST) Message-Id: <4.2.2.20000104141301.00ad34b0@mail.venux.net> X-Sender: mhagerty@mail.venux.net X-Mailer: QUALCOMM Windows Eudora Pro Version 4.2.2 Date: Tue, 04 Jan 2000 14:27:52 -0500 To: Jan Wieck , Mitch Vincent From: Matthew Hagerty Subject: Re: [SQL] Triggers Cc: pgsql-sql@postgreSQL.org In-Reply-To: <38723F15.9EADB8A7@debis.com> References: <21582.943985242@sss.pgh.pa.us> <00cc01bf56c5$03cd5e80$40ee2fd8@venux.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed The system config is: P2-400, 256Meg ECC, 1 SCSI WDE9180 ULTRA2, FreeBSD-3.3-Release, gcc-2.7.2.1, pg-6.5.1. That is the development server, our operational server is: Dual P2-333, 256Meg ECC, 3 SCSI, FreeBSD-3.3-Release, gcc-2.7.2.1, pg-6.5.3. The trigger is untested on the operational server as of yet. Matthew (works with Mitch) At 07:42 PM 1/4/00 +0100, Jan Wieck wrote: >Mitch Vincent wrote: > > > 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 ' > > ... > > > > 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 wonder why it works on UPDATE at all, it shouldn't. It is an > AFTER ROW trigger and thus, the changed row you return should get > ignored. Use BEFORE INSERT instead. > > But that it works on UPDATE indicates some bug somewhere. What > release, OS, etc. are you using? > >Jan > >-- > >#======================================================================# ># It's easier to get forgiveness for being wrong than for being right. # ># Let's break this rule - forgive me. # >#========================================= wieck@debis.com (Jan Wieck) # > > > > >************