Re: 'record old is unassigned yet' when using trigger in 7.1.1 - Mailing list pgsql-sql

From Joe Conway
Subject Re: 'record old is unassigned yet' when using trigger in 7.1.1
Date
Msg-id 000c01c0d8d2$cefddf90$54d410ac@jecw2k1
Whole thread Raw
In response to 'record old is unassigned yet' when using trigger in 7.1.1  (Joseph Shraibman <jks@selectacast.net>)
List pgsql-sql
>        begin
>      IF OLD.status <> NEW.status
>      THEN
> NEW.statchangedate = CURRENT_DATE;
>      END IF;
> return NEW;
> end;
>
> The problem is when a new row is inserted I get this error message:
> ERROR:  record old is unassigned yet
> ... and the insert fails.
>
> It doesn't matter if the trigger is before or after.

OLD doesn't exist on inserts, only on update and delete. If you want to use
the same function for both insert and update use the TG_OP variable and an
if statement. See
http://www.postgresql.org/idocs/index.php?plpgsql-trigger.html

Hope this helps,

Joe





pgsql-sql by date:

Previous
From: Joseph Shraibman
Date:
Subject: 'record old is unassigned yet' when using trigger in 7.1.1
Next
From: Michael Davis
Date:
Subject: RE: 'record old is unassigned yet' when using trigger in 7.1.1