Solved

general

Posted on 2011-03-17
4
285 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
Comment Utility
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
Comment Utility
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
Comment Utility
gud and fast response
0
 
LVL 15

Expert Comment

by:gplana
Comment Utility
Excellent. Thank you.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

763 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

6 Experts available now in Live!

Get 1:1 Help Now