Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Division by zero: how to handle?
A followup to my posting:
I know I could write some code like
decode (a, 0, 0, b/a)
But in my case, this wouldn't work, because the expression in the select
statement is built at runtime:
Users enter a formula like "$1+$2/($3+$4)) which is then translated to SQL
(Variabes are replaced by fields)
So hopefully there is some simple oracle way to handle Dib by Zero. (Else, I would need to write a complete expression parser... :-( )
-- Georg Scholz www.scholz-informatik.at "Georg Scholz" <georg.scholz_at_vienna.at> schrieb im Newsbeitrag news:...Received on Wed Jun 04 2003 - 08:29:59 CDT
> Dear all,
>
> This might look like a simple question, but I didn't find a clue in the
> manuals:
>
> Is there a way to handle divisions by zero?
>
> SELECT a / b FROM ...
>
> Problem: When some record produces a division by zero, then the SQL
> statements STOPS and no more records are delivered.
> When posting the statement via ADO, then I get an error message.
>
> --> So: Is there some function like "NVL" to handle divions by zero ?
> (e.g. the expression it should deliver NULL or some other value)
>
> Any hint is highly appreciated
> Thank you
> Georg Scholz
> ---
> www.scholz-informatik.at
>
>