x
login about faq Site discussion (meta-askssc)

Divided by 0 exception error?

We created a procedure, where there is a formula as follows.

Count:=Avl/cnter

Here some times the cnter value is coming 0. So the procedure is throughing an exception. How can we handle this error in pl/sql procedure?

more ▼

asked Dec 09 '09 at 07:04 PM in Default

dbkid gravatar image

dbkid
131 3 8 10

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

You could avoid the error altogether, don't divide when 0, just return a 0 (or some other value):

count = case when cntr <> 0 then avl/cntr else 0 end
more ▼

answered Dec 10 '09 at 02:33 AM

KillerDBA gravatar image

KillerDBA
1.5k 5 9 10

Yep KillerDBA. This case statement solved the eror. Thank you.

Dec 10 '09 at 09:19 PM dbkid
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x50

asked: Dec 09 '09 at 07:04 PM

Seen: 235 times

Last Updated: Dec 09 '09 at 07:04 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.