Re: ON DELETE trigger blocks delete from my table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Naeem Bari" <naeem(dot)bari(at)agilissystems(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ON DELETE trigger blocks delete from my table
Date: 2004-10-25 19:47:35
Message-ID: 22906.1098733655@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Naeem Bari" <naeem(dot)bari(at)agilissystems(dot)com> writes:
> CREATE OR REPLACE FUNCTION public.func_job_status_upd()
> RETURNS trigger AS
> '
> begin
> insert into x_job_status values ( OLD.job_id, OLD.job_status_type_id,
> OLD.status_date, OLD.notes, OLD.edit_person_id, OLD.edit_date);
> return new;
> end;
> '
> LANGUAGE 'plpgsql' VOLATILE;

If this is a BEFORE trigger, you probably need "RETURN OLD". "NEW" will
be NULL in a delete trigger, so you're returning NULL which cancels the
operation.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2004-10-25 19:50:23 Re: ON DELETE trigger blocks delete from my table
Previous Message Tom Lane 2004-10-25 19:45:44 Re: Arrays, placeholders, and column types