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 00c201c0d8e2$b3706530$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
> ... but that had the same problem.  So then I tried:
> 
> create function utbl_set_statchangedate() returns opaque as 
> 'begin 
>      IF TG_OP = \'UPDATE\'
>      THEN
>      NEW.statchangedate := CURRENT_DATE;
>      ELSE IF OLD.status <> NEW.status
>      THEN
> NEW.statchangedate := CURRENT_DATE;
>      END IF;
> return NEW;
> end;
> ' language 'plpgsql';

There is no "else if" in plpgsql, if I remember correctly. Try:

create function utbl_set_statchangedate() returns opaque as 
'begin     IF TG_OP = ''UPDATE'' THEN        NEW.statchangedate := CURRENT_DATE;    ELSE        IF OLD.status <>
NEW.statusTHEN            NEW.statchangedate := CURRENT_DATE;        END IF;    END IF;
 
return NEW;
end;
' language 'plpgsql';

-- Joe



pgsql-sql by date:

Previous
From: Joseph Shraibman
Date:
Subject: Re: 'record old is unassigned yet' when using trigger in 7.1.1
Next
From: "Joe Conway"
Date:
Subject: Re: 'record old is unassigned yet' when using trigger in 7.1.1