row not deleted but updated (trigger?)

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-sql(at)postgresql(dot)org
Subject: row not deleted but updated (trigger?)
Date: 2009-02-27 11:56:06
Message-ID: 20090227125606.73d48d8e@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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;

create trigger FT1IDX_catalog_brands_update_trigger before update or
delete on catalog_brands for each row execute procedure
FT1IDX_catalog_brands_update();

I do something
update catalog_brands set name='zzz' where brandid=1234;
1 row get updated.

When I do
delete from catalog_brands where brandid=1234;
no row get deleted and no error get reported.

what did I miss?

thanks

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2009-02-27 12:21:49 Re: row not deleted but updated (trigger?)
Previous Message Steve Midgley 2009-02-25 18:42:49 Re: Best practices for geo-spatial city name searches?