basic trigger using OLD not working?

From: Rick Casey <rick(dot)casey(at)colorado(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: basic trigger using OLD not working?
Date: 2005-02-24 21:22:20
Message-ID: 421E458C.4070807@colorado.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello all,

I am trying to a simple thing: create a log history of deletes, and
updates; but which I am having trouble getting to work in PG 7.4.7
(under Debian Linux 2.6.8).

I have reduced my code to the following trivial case:

Here is the code that creates the delete trigger:
create trigger PEDIGREES_hist_del_trig
AFTER DELETE
on PEDIGREES
EXECUTE PROCEDURE logPedigreesDel();

Here is the trigger code: (famindid is an integer field in the Pedigrees
table):

CREATE OR REPLACE FUNCTION logPedigreesDel() RETURNS TRIGGER AS '
DECLARE
test integer;
begin
test := OLD.famindid;
RAISE EXCEPTION ''OLD.famindid = '', test;
return OLD;
end;
' LANGUAGE plpgsql;

Here is the error message returned:
psql:testphdtrig.sql:1: ERROR: record "old" is not assigned yet
DETAIL: The tuple structure of a not-yet-assigned record is indeterminate.
CONTEXT: PL/pgSQL function "logpedigreesdel" line 4 at assignment

Would *really appreciate* any suggestions! This could help us decide
whether to PostGres for a major project...

thanks --rick

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron Mayer 2005-02-24 21:52:59 Re: [PATCHES] A way to let Vacuum warn if FSM settings are low.
Previous Message Bruce Momjian 2005-02-24 21:20:03 Re: Pg 8.01 big trouble with LIMIT (bug !?)