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: Chris ( Val ) <chrisval_at_bigpond.com.au>
Date: 20 Jun 2005 15:07:12 -0700
Message-ID: <1119305232.649511.121790@g49g2000cwa.googlegroups.com>

tq wrote:
> Question about this case statement below - is it actually evaluating
> the 3=3 or does it short ciruit? I'm trying to judge decode versus case
> in terms of potential performance differences.
>
> case when 1=2 and 3=3 then 0 else 1 end

Actually (and if I understand you correctly) in this context, your question should probably rather be about how the logical "AND" operation works.

The statement: "1=2 and 3=3" is itself the expression being tested for, so the whole thing must evaluate to true for a zero to be returned, otherwise a one will be returned.

Both parts of the expression must be true, for the whole expression to be evaluated as true. If the first part of the expression is false, then it stands to reason that the rest of the expression *will not* be evaluated, because both *have to be true* for the whole expression to return true.

As far as efficiency goes, I have read that "CASE" statements are more efficient that "DECODE" statements, and they have the added advantage of being ANSI compliant.

Cheers,
Chris Val Received on Mon Jun 20 2005 - 17:07:12 CDT

Original text of this message

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