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

Home -> Community -> Usenet -> c.d.o.server -> Re: case short circuits?

Re: case short circuits?

From: Andy Hassall <andy_at_andyh.co.uk>
Date: Tue, 21 Jun 2005 19:37:08 +0100
Message-ID: <mbngb1pc54qsbdvbkmvv0g8jbnpd0os188@4ax.com>


On 20 Jun 2005 16:46:09 -0700, "tq" <tomm_quinn_at_yahoo.com> wrote:

>Andy, thanks for the input. The example is helpful. Although I assumed
>as much from a logical standpoint, I was still curious to know since
>certain other functions such as nvl will not short-circuit regardless
>of the first argument being null or not.

 Well, I didn't know that, I assumed nvl() short-ciruited since that'd be sensible. I've started to use COALESCE more recently, since it's a more "Standard" function compared with the Oracle-specific NVL, and in the two-argument case it's equivalent, but can take more arguments when required. But it turns out it may even be more efficient, as it apparently does short-circuit:

SQL> select nvl(f1(), f2()) from dual;

NVL(F1(),F2())


             1
f1
f2

SQL> select coalesce(f1(), f2()) from dual;

COALESCE(F1(),F2())


                  1

f1
-- 
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Received on Tue Jun 21 2005 - 13:37:08 CDT

Original text of this message

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