Solved

general

Posted on 2011-03-17
4
286 Views
Last Modified: 2012-05-11
Hi

In a scenario where there is a divison
and the divisor is zero
i shd get a result directly as zero
ex
a = 1
b = 0
c = a/b
in above case the error will be divisor zero
so i shd get output directly as '0'

help me
0
Comment
Question by:iamtechnical
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
gplana earned 125 total points
ID: 35159848
I'm not sure if I understood your question, but to avoid the divide by zero error you should do something like this:

a = 1
b = 0

if b=0 then
   c = 0
else
   c = a/b
end if

Please note that the notation used could differ depending on the language, so if for example you want to write this in C or Java, you should write:

a = 1;
b = 0;

if (b==0) {
   c = 0;
}
else {
   c = a/b;
}

Hope it helps.
0
 

Author Comment

by:iamtechnical
ID: 35159882
yup

u got it write

but i was confused

actually i used sql

so here it is

decode(b,0,0,a/b) as c

0
 

Author Closing Comment

by:iamtechnical
ID: 35159886
gud and fast response
0
 
LVL 15

Expert Comment

by:gplana
ID: 35160294
Excellent. Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to recover a database from a user managed backup

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now