From: | Jan Wieck <JanWieck(at)Yahoo(dot)com> |
---|---|
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:50:23 |
Message-ID: | 417D58FF.90606@Yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 10/25/2004 2:56 PM, Naeem Bari wrote:
> Hi,
>
> I am using postgres 7.4.5 on Redhat Enterprise Linux 3.
>
> My background is really on Oracle, and I am porting a largish database
> over to postgres.
>
> Here is my problem:
>
> On oracle, I had a table with an "on update or delete" trigger that
> copied the current row out to an audit table. Works like a champ. On
> postgres, when I try to delete a row, all it gives back to me is "DELETE
> 0" and does nothing.
>
> Here is the text of the trigger:
>
> ~~~~~~~~~~
> 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;
There is no NEW row on DELETE. You can either let the trigger fire
AFTER, causing its return value to be ignored, or define different
trigger procedures for UPDATE/DELETE, or you can check inside the
trigger for which event it was actually fired and return NEW/OLD
accordingly.
Jan
> end;
> '
> LANGUAGE 'plpgsql' VOLATILE;
> ~~~~~~~~~~
>
> Any help would be appreciated!
>
> Thanks,
> naeem
>
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2004-10-25 19:52:22 | Re: ON DELETE trigger blocks delete from my table |
Previous Message | Tom Lane | 2004-10-25 19:47:35 | Re: ON DELETE trigger blocks delete from my table |