Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL Beginner Question ...

Re: PL/SQL Beginner Question ...

From: DA Morgan <damorgan_at_psoug.org>
Date: Thu, 05 Apr 2007 11:37:49 -0700
Message-ID: <1175798265.271459@bubbleator.drizzle.com>


cdecarlo wrote:
> Hello,
>
> I'm just reviewing some pl/sql code that I've been given and I was
> wondering if someone could educate me regarding how a pl/sql IF
> statement is evaluated, does it short circuit the evaluation once one
> truth is determined or does it evaluate the entire expression? Does it
> evaluate left to right or right to left?
>
> Also, are these two blocks contextually the same? Which uses better
> style?
>
> Firstly consider there are functions titled functionX where X is a
> number from 1 to 4, each function will return a boolean value.
>
> IF NOT function1
> THEN IF NOT function2
> THEN IF NOT function3
> THEN IF NOT function4
> THEN
> statement;
> END IF;
> END IF:
> END IF;
> END IF;
> END IF;
>
> vs.
>
> IF function1 THEN
> statement;
> ELSEIF function2 THEN
> statement;
> ELSEIF function3 THEN
> statement;
> ELSEIF function4 THEN
> statement;
> ELSE
> statement;
> END IF;
>
> Thanks,
>
> cdecarlo

At the first expression that returns true it follows that branch. Nothing thereafter is evaluated.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Thu Apr 05 2007 - 13:37:49 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US