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: Division by zero: how to handle?

Re: Division by zero: how to handle?

From: Norman Dunbar <Oracle_at_MSSQLBountifulSolutions.co.uk>
Date: Fri, 06 Jun 2003 07:48:18 +0100
Message-ID: <bbpdcj$s54$1$8300dec7@news.demon.co.uk>


ctcgag_at_hotmail.com wrote:

> Is there something like that for within a single query?
>
> select 1/(rownum-5) from tab; -- as a user with > 5 tables
>
> The whole query aborts, rather than just ignoring the row that would have
> an error.
>

Morning Xho,

how about using decode as another poster mentioned :

select 1/decode((rownum-5), 0, Something, (rownum-5)) from tab;

SQL> select rownum,1/decode((rownum-5),0,1e12,(rownum-5)) from hr.employees   2* where rownum < 10

    ROWNUM 1/DECODE((ROWNUM-5),0,1E12,(ROWNUM-5))
---------- --------------------------------------
         1                                   -.25
         2                             -.33333333
         3                                    -.5
         4                                     -1
         5                             1.0000E-12
         6                                      1
         7                                     .5
         8                             .333333333
         9                                    .25

9 rows selected.

Cheers,
Norman.

-- 
Remove a certain other database to reply :o)
Received on Fri Jun 06 2003 - 01:48:18 CDT

Original text of this message

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