Re: ON DELETE trigger blocks delete from my table - Mailing list pgsql-general

From Tom Lane
Subject Re: ON DELETE trigger blocks delete from my table
Date
Msg-id 22906.1098733655@sss.pgh.pa.us
Whole thread Raw
In response to ON DELETE trigger blocks delete from my table  ("Naeem Bari" <naeem.bari@agilissystems.com>)
Responses Re: ON DELETE trigger blocks delete from my table
List pgsql-general
"Naeem Bari" <naeem.bari@agilissystems.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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Arrays, placeholders, and column types
Next
From: Jan Wieck
Date:
Subject: Re: ON DELETE trigger blocks delete from my table