Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: case short circuits?
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
-- Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk> <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis toolReceived on Tue Jun 21 2005 - 13:37:08 CDT
![]() |
![]() |