Re: How to notice column changes in trigger - Mailing list pgsql-sql

From Andreas Pflug
Subject Re: How to notice column changes in trigger
Date
Msg-id 3E6E026C.4090407@web.de
Whole thread Raw
In response to Re: How to notice column changes in trigger  (Aspire Something <sank89@sancharnet.in>)
List pgsql-sql
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




pgsql-sql by date:

Previous
From: Christoph Haller
Date:
Subject: Re: Special characters in SQL queries
Next
From: Terry Lee Tucker
Date:
Subject: Novice needs help