Re: ON DELETE trigger blocks delete from my table

From: Edmund Bacon <ebacon-xlii(at)onesystem(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: ON DELETE trigger blocks delete from my table
Date: 2004-10-25 20:15:55
Message-ID: m3acuah7ut.fsf@elb_lx.onesystem.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

naeem(dot)bari(at)agilissystems(dot)com ("Naeem Bari") writes:

> I understand. Makes sense. Is there anyway for my trigger function to
> "know" that it is being called on a delete or on an update? Because I do
> need to "return new" on update... and I really don't want to write 2
> different functions, one for update and one for delete...
>

Yes, plpgsql sets a variable TG_OP to INSERT, UPDATE or DELETE.

so, for example

IF ( TG_OP = ''DELETE'' ) THEN
RETURN old;
ELSE
RETURN new;
END IF;

--
Remove -42 for email

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2004-10-25 20:16:26 Re: ON DELETE trigger blocks delete from my table
Previous Message Naeem Bari 2004-10-25 20:09:30 Re: ON DELETE trigger blocks delete from my table