Re: How to notice column changes in trigger

From: Andreas Pflug <Andreas(dot)Pflug(at)web(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to notice column changes in trigger
Date: 2003-03-11 15:36:12
Message-ID: 3E6E026C.4090407@web.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Terry Lee Tucker 2003-03-11 17:47:37 Novice needs help
Previous Message Christoph Haller 2003-03-11 15:32:33 Re: Special characters in SQL queries