Re: row not deleted but updated (trigger?) - Mailing list pgsql-sql

From Ivan Sergio Borgonovo
Subject Re: row not deleted but updated (trigger?)
Date
Msg-id 20090227132149.538720d5@dawn.webthatworks.it
Whole thread Raw
In response to row not deleted but updated (trigger?)  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
List pgsql-sql
On Fri, 27 Feb 2009 12:56:06 +0100
Ivan Sergio Borgonovo <mail@webthatworks.it> wrote:

> I've:
> 
> create or replace function FT1IDX_catalog_brands_update() returns
> trigger as $$
> begin
> if(TG_OP='DELETE') then
>   update catalog_items set
>     FT1IDX=GetFTIDX('pg_catalog.english', Code, CodeAlt, ISBN,
> Name, Authors, '')
>       where BrandID=old.BrandID;
> else
>   if(coalesce(new.Name,'')<>coalesce(old.Name,'')) then
>     update catalog_items set
>       FT1IDX=GetFTIDX('pg_catalog.english', Code, CodeAlt, ISBN,
>         Name, Authors, new.Name)
>          where BrandID=new.BrandID;
>   end if;
> end if;
> return new;
> end $$ language plpgsql volatile;

umpfs...
on delete new is null... so no action take place.
modified to return old on delete and new for the rest.
Sorry for the noise.

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it



pgsql-sql by date:

Previous
From: Ivan Sergio Borgonovo
Date:
Subject: row not deleted but updated (trigger?)
Next
From: "Igor Neyman"
Date:
Subject: Re: row not deleted but updated (trigger?)