Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Division by zero: how to handle?
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