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: "IF" equivilent in SQL select?????

Re: "IF" equivilent in SQL select?????

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Thu, 06 May 1999 14:20:00 GMT
Message-ID: <3731a4ca.2020154@192.86.155.100>


A copy of this was sent to "Vickie Jones" <vjones1_at_nci2000.net> (if that email address didn't require changing) On Thu, 6 May 1999 09:05:06 -0400, you wrote:

>Is there a function(?) that would be the equivilent to an "IF" statment that
>can be used in a select statment? Below is a sample of what I am trying to
>do and the results:
>
>analyze index ccdbp.ALARMS_CODES_KEY validate structure;
>col key_name format A50
>select 'ALARMS_CODES_KEY' as key_name,del_lf_rows/lf_rows "Ratio" from
>index_stats;
>

select 'ALARMS_CODES_KEY' as key_name,

        decode( nvl(lf_rows,0), 0, null, del_lf_rows/lf_rows) ratio    from index_stats

will return NULL if lf_rows is null or zero, returns the ratio otherwise.

>ERROR:
>ORA-01476: divisor is equal to zero
>
>What I need is an "if" statement that says if lf_rows is 0 (zero) set
>'del_lf_rows/lf_rows' to 0 (zero). I want to eliminate this error when I
>analyze my indexes.
>
>Thanks in advance!
>Vickie Jones
>Republic Engineered Steels, Inc.
>Canton, OH
>

See http://www.oracle.com/ideveloper/ for my column 'Digging-in to Oracle8i'...  

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA

--
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Thu May 06 1999 - 09:20:00 CDT

Original text of this message

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