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: Attempting to get Result as "%"

Re: Attempting to get Result as "%"

From: <mjbox01_at_gmail.com>
Date: 3 Feb 2006 05:05:33 -0800
Message-ID: <1138971933.356881.55030@g43g2000cwa.googlegroups.com>

Mark C. Stock wrote:

> you'll need to use a CASE expression to convert a 0 divisor to 1 to avoide
> the ORA-01476

I see this a lot and I have never understood it, as it will return essentially random data, e.g.

20/2 will be equal to 10/0 which it obviously is not.

And what is the fear of null, if you have a null return it don't put some random value in there. I would argue that n/0 should be returned as null or 'NA'. In which case the select should simply be

select case when on_duty <> then
  to_char(production / on_duty * 100) || '%' end,

or

select case when on_duty <> then
  to_char(production / on_duty * 100) || '%' else
  'NA'
end, Received on Fri Feb 03 2006 - 07:05:33 CST

Original text of this message

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