Evaluation of if conditions

From: Daniel CAUNE <d(dot)caune(at)free(dot)fr>
To: pgsql-sql(at)postgresql(dot)org
Subject: Evaluation of if conditions
Date: 2006-09-06 22:32:40
Message-ID: 001601c6d204$5d2cd840$0b00a8c0@tedy
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

How does the IF statement evaluate conditions? Does it evaluate conditions
following their declaration order from left to right? In case of
or-conditions, does the IF statement stop evaluating conditions whenever a
first or-condition is true?

The following snippet seems to be invalid, which let me think that PL/PGSQL
evaluates all the conditions:

IF (TG_OP = 'INSERT') OR
(OLD.bar = ...) THEN
statement
END IF;

Should be rewritten as (for example):

IF (TG_OP = 'INSERT') THEN
statement
ELSIF (OLD.bar = ...) THEN
statement
END IF;

Regards,

--
Daniel

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gregory S. Williamson 2006-09-06 23:02:30 Re: Evaluation of if conditions
Previous Message Daryl Richter 2006-09-06 20:20:37 Re: Substitute a Character