pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Wieck <wieck@debis.com>
To: Mitch Vincent <mitch@venux.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Triggers
Date: Tue, 04 Jan 2000 19:42:29 +0100
Message-ID: <38723F15.9EADB8A7@debis.com> (raw)
References: <21582.943985242@sss.pgh.pa.us>
	<00cc01bf56c5$03cd5e80$40ee2fd8@venux.net>

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) #






view thread (34+ messages)  latest in thread

Message-ID: <38723F15.9EADB8A7@debis.com>
Permalink:  ../38723F15.9EADB8A7@debis.com/
Also on:    postgresql.org/message-id/38723F15.9EADB8A7@debis.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: wieck@debis.com, mitch@venux.net
  Subject: Re: [SQL] Triggers
  In-Reply-To: <38723F15.9EADB8A7@debis.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox