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: Brian Peasland <oracle_dba_at_remove_spam.peasland.com>
Date: Wed, 4 Jun 2003 14:29:11 GMT
Message-ID: <3EDE0236.560DF3E6@remove_spam.peasland.com>


You'll probably have to code your routine in a PL/SQL block and then catch an exception when this error occurs. Your exception handling routine can then decide what to do next.

HTH,
Brian

Georg Scholz wrote:
>
> 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:...
> > 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
> >
> >

-- 
===================================================================

Brian Peasland
oracle_dba_at_remove_spam.peasland.com

Remove the "remove_spam." from the email address to email me.


"I can give it to you cheap, quick, and good. Now pick two out of
 the three"
Received on Wed Jun 04 2003 - 09:29:11 CDT

Original text of this message

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