Home » SQL & PL/SQL » SQL & PL/SQL » ora:01476 divisor is equal to zero (oracle 10g on XP)
ora:01476 divisor is equal to zero [message #442425] Sun, 07 February 2010 23:42 Go to next message
nehaverma
Messages: 80
Registered: January 2010
Location: JAIPUR
Member
hello

please help.
I found an error when I run report from parameter december date only and when i run same report from november it runs without an error.
error:rep:1401-cf_per_tot_recpformula
and my formula is:
function CF_PER_TOT_RECPFormula return Number is
X NUMBER := 0;
begin
IF :TOT_RECP <> 0 THEN
X := ( (:TOT_RECP/:SumTOT_RECPPerPL_MAIN_GRP) * 100 );
ELSE
X := 0;
END IF;
RETURN(X);
end;

regard//
neha
Re: ora:01476 divisor is equal to zero [message #442430 is a reply to message #442425] Mon, 08 February 2010 00:34 Go to previous messageGo to next message
halim
Messages: 100
Registered: September 2008
Senior Member

Try to run with this code:-
and you find that your :SumTOT_RECPPerPL_MAIN_GRP field return
a Zero for at least one row in december months.
So you should to handle this in your own way.

function CF_PER_TOT_RECPFormula return Number is
X NUMBER := 0;
begin
IF :TOT_RECP <> 0 THEN
-----------------------------------
 if nvl(:SumTOT_RECPPerPL_MAIN_GRP,0)=0 then 
 :SumTOT_RECPPerPL_MAIN_GRP=1;
 end if;
----------------------------------- 
X := ( (:TOT_RECP/:SumTOT_RECPPerPL_MAIN_GRP) * 100 );
ELSE
X := 0;
END IF;
RETURN(X);
end;



This is just for testing purpose.

Regards
Halim

[Updated on: Mon, 08 February 2010 00:35]

Report message to a moderator

Re: ora:01476 divisor is equal to zero [message #442438 is a reply to message #442425] Mon, 08 February 2010 01:08 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Quote:
IF :TOT_RECP <> 0 THEN
X := ( (:TOT_RECP/:SumTOT_RECPPerPL_MAIN_GRP) * 100 );
ELSE
X := 0;


You are testing the wrong bit. If :TOT_RECP == 0, then X will become 0 with the first expression anyway. What you wanted to test is if :SumTOT_RECPerPL_MAIN_GRP != 0.
Re: ora:01476 divisor is equal to zero [message #442446 is a reply to message #442438] Mon, 08 February 2010 01:25 Go to previous message
halim
Messages: 100
Registered: September 2008
Senior Member

I am just wanted to say that


SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 8 13:17:38

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL> conn halim@test107
Enter password:
Connected.
SQL>
SQL>
SQL> select  (1  / 1 ) * 100  from dual
  2  /

 (1/1)*100
----------
       100

SQL> select  (0  / 1 ) * 100  from dual
  2  /

 (0/1)*100
----------
         0

SQL> select  (1  / 0 ) * 100  from dual
  2  /
select  (1  / 0 ) * 100  from dual
            *
ERROR at line 1:
ORA-01476: divisor is equal to zero


SQL>



Regards
Halim

[Updated on: Mon, 08 February 2010 01:27]

Report message to a moderator

Previous Topic: Find out date range for last 4 and 52 weeks
Next Topic: Bad running queries
Goto Forum:
  


Current Time: Thu May 22 13:29:23 CDT 2025