From: sad <sad@bankir.ru>
To: pgsql-sql@postgresql.org
Subject: Re: Reg: Firing Trigger when a particular column value get changed
Date: Mon, 22 Sep 2003 09:21:56 +0400
Message-ID: <200309220921.56092.sad@bankir.ru> (raw)
In-Reply-To: <3F6CD6E9.5030005@houle.org>
References: <63970.192.168.64.193.1063969270.squirrel@mail2.siptech.co.in>
<3F6CD6E9.5030005@houle.org>
On Sunday 21 September 2003 02:38, you wrote:
> Thilak babu wrote:
> > I have a scnerio as to fire a trigger when i update a particular column
> > in a table. Please do help me out in getting thro this.
>
> The trigger function can use logic to exclude cases where a particular
> column does not change. For example:
>
> CREATE FUNCTION "column_update" () RETURNS TRIGGER AS '
> BEGIN
> IF ( NEW.column <> OLD.column ) THEN
> do-your-stuff-here;
> END IF;
> RETURN NEW;
> END; ' LANGUAGE 'plpgsql';
this trigger will not execute "your-stuff-here"
if NEW.column or OLD.column will be null.
you need to add this case to the logic statement in the "IF"
(NEW.column <> OLD.column) OR (NEW.column IS NULL <> OLD.column. IS NULL)
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: sad@bankir.ru
Subject: Re: Reg: Firing Trigger when a particular column value get changed
In-Reply-To: <200309220921.56092.sad@bankir.ru>
* 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