Solved

general

Posted on 2011-03-17
4
287 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle RAC 12c 8 73
case statement in where clause with not exist 15 52
Oracle Insert not working 10 28
ORA-02288: invalid OPEN mode 2 31
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
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 Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

810 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