Solved

general

Posted on 2011-03-17
4
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

635 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