pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Pflug <Andreas.Pflug@web.de>
To: pgsql-sql@postgresql.org
Subject: Re: How to notice column changes in trigger
Date: Tue, 11 Mar 2003 16:36:12 +0100
Message-ID: <3E6E026C.4090407@web.de> (raw)
In-Reply-To: <002001c2e78b$642e6df0$c9c832c0@societykotla>
References: <3E6CA287.2EE21BFB@rodos.fzk.de>
	<002001c2e78b$642e6df0$c9c832c0@societykotla>


Aspire Something wrote:
> Hello Christoph Haller ,
> 
> 
> 
>>>>So you want the trigger executed only if assignments to b and/or c do
> 
> 
> Do sime thing like this  use if /then /esle s block for the problem
> 
> In the first if blick check that b and c is null by the declaration of 
> IS NULL after that you run the update command as required 
> 
> The program code will show as
> 
> create function 
> CREATE FUNCTION BLAH_FUNCTION() RETURNS "trigger"
>     AS ' 
> usual blah blah of declre and all ,
> 
> 
> IF NEW.b IS NULL and NEW.C IS NULL THEN
> ROCK BABY
> ELSE
> Do OTHERWISE
> END IF;
> more blah blah plpgsql';
> 
> 
Sorry,
this won't work at all.
The NEW will contain the new row contents, and that may well be non-null 
for columns not mentioned in the update query. This kind of code will 
perform well on inserts, but not on updates of well-populated rows.
Core SQL or PL/PGSQL statements won't do the job.

Regards,
Andreas





view thread (9+ messages)  latest in thread

Message-ID: <3E6E026C.4090407@web.de>
Permalink:  ../3E6E026C.4090407@web.de/
Also on:    postgresql.org/message-id/3E6E026C.4090407@web.de

 · 

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: Andreas.Pflug@web.de
  Subject: Re: How to notice column changes in trigger
  In-Reply-To: <3E6E026C.4090407@web.de>

* 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