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

From Igor Neyman
Subject Re: row not deleted but updated (trigger?)
Date
Msg-id F4C27E77F7A33E4CA98C19A9DC6722A204218178@EXCHANGE.corp.perceptron.com
Whole thread Raw
In response to row not deleted but updated (trigger?)  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
List pgsql-sql
"delete" trigger should return "old".
In your code you return "new" for both: "update" and "delete"

Igor

-----Original Message-----
From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Ivan Sergio
Borgonovo
Sent: Friday, February 27, 2009 6:56 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] row not deleted but updated (trigger?)

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


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



pgsql-sql by date:

Previous
From: Ivan Sergio Borgonovo
Date:
Subject: Re: row not deleted but updated (trigger?)
Next
From: Carol Cheung
Date:
Subject: counts of groupings by date year-month