PL/pgSQL evaluation order

From: Mark Volpe <volpe(dot)mark(at)epamail(dot)epa(dot)gov>
To: pgsql-sql(at)postgresql(dot)org
Subject: PL/pgSQL evaluation order
Date: 2000-08-03 15:30:27
Message-ID: 39899013.AA9243EC@epamail.epa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I have trigger function with the statement:

IF TG_OP=''INSERT'' OR NEW.ip!=OLD.ip THEN

expecting the TG_OP=''INSERT'' to be evaluated
first, and if true, proceed with the body.
But it gets evaluated as the result of an INSERT
statement, I get a (rather strangly worded) error:

ERROR: record old is unassigned yet

which means that the second statement is still being
evaluated even though the first is true. Assuming
that this is the result of the parser/planner messing
with that statement, is there a way to force evaluation
order without having to go:

IF TG_OP=''INSERT'' THEN
<body>
ELSE
IF NEW.OP!=OLD.ip THEN
<repeat body>
END IF;
END IF;

Thanks,
Mark

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Volpe 2000-08-03 15:33:36 Re: PL/pgSQL
Previous Message Tom Lane 2000-08-03 15:20:44 Re: a question about dates and timestamp