Home » Developer & Programmer » Reports & Discoverer » oracle report problem
oracle report problem [message #153982] Thu, 05 January 2006 04:10 Go to next message
shatishr
Messages: 52
Registered: September 2005
Location: Shah Alam
Member
hie all
im having a slight trouble here with my oracle report


PROCEDURE get_gap IS
  v_reload_amount_ain number(12);
  v_reload_amount_ppb number(12);
  v_number_reload_ain number(12);
  v_number_reload_ppb number(12);
  
BEGIN
  v_reload_amount_ain := 0;
  v_reload_amount_ppb := 0;
  v_number_reload_ain := 0;
  v_number_reload_ppb := 0;
  :CP_1 := 0;
  :CP_2 := 0;
  :CP_3 := 0;
  :CP_4 := 0;
  
  select sum(reload_amount), count(reload_amount)
  into v_reload_amount_ain, v_number_reload_ain
  from trap_ra_k2_ain_balance 
  where week_no = :p_week;
  
  
  select sum(reload_amount), count(reload_amount)
  into v_reload_amount_ppb, v_number_reload_ppb
  from trap_ra_k1_ppb_balance 
  where week_no = :p_week;
  
  
  :CP_1 := v_reload_amount_ain - v_reload_amount_ppb;
  :CP_2 := v_number_reload_ain - v_number_reload_ppb;
  
  -- checking for 0 divisor
  if (v_reload_amount_ppb) > 0 then
    :CP_3 := abs(ROUND(:CP_1/(v_reload_amount_ain + v_reload_amount_ppb) *100,2));
  else 
    :CP_3 := 0;
  end if;
  
  -- checking for 0 divisor
  if (v_number_reload_ppb) > 0 then
    :CP_4 := abs(ROUND(:CP_2/(v_number_reload_ain + v_number_reload_ppb) *100,2));
  else
  	:CP_4 := 0;
  end if;

END;


the problem here is CP1 is not returning any data in the report it is empty... i tried manually extracting this from db and the sum column is null since there is no data for that particular week for this table

select sum(reload_amount), count(reload_amount)
from trap_ra_k1_ppb_balance 
where week_no = 53


what i want is, wherever there is null, it should replace to 0 in
v_reload_amount_ain number(12); and
v_reload_amount_ppb number(12);


any help ?
Re: oracle report problem [message #154014 is a reply to message #153982] Thu, 05 January 2006 06:39 Go to previous messageGo to next message
benoitchabot
Messages: 15
Registered: October 2005
Location: Quebec , Canada
Junior Member
Try this:

PROCEDURE get_gap IS
v_reload_amount_ain number(12);
v_reload_amount_ppb number(12);
v_number_reload_ain number(12);
v_number_reload_ppb number(12);

BEGIN
:CP_1 := 0;
:CP_2 := 0;
:CP_3 := 0;
:CP_4 := 0;

select sum(reload_amount), count(reload_amount)
into v_reload_amount_ain, v_number_reload_ain
from trap_ra_k2_ain_balance
where week_no = :p_week;


select sum(reload_amount), count(reload_amount)
into v_reload_amount_ppb, v_number_reload_ppb
from trap_ra_k1_ppb_balance
where week_no = :p_week;

v_reload_amount_ain := nvl(v_reload_amount_ain, 0);
v_reload_amount_ppb := nvl(v_reload_amount_ppb, 0);
v_number_reload_ain := nvl(v_number_reload_ain, 0);
v_number_reload_ppb := nvl(v_number_reload_ppb, 0);

:CP_1 := v_reload_amount_ain - v_reload_amount_ppb;
:CP_2 := v_number_reload_ain - v_number_reload_ppb;

-- checking for 0 divisor
if (v_reload_amount_ppb) > 0 then
:CP_3 := abs(ROUND(:CP_1/(v_reload_amount_ain + v_reload_amount_ppb) *100,2));
else
:CP_3 := 0;
end if;

-- checking for 0 divisor
if (v_number_reload_ppb) > 0 then
:CP_4 := abs(ROUND(:CP_2/(v_number_reload_ain + v_number_reload_ppb) *100,2));
else
:CP_4 := 0;
end if;

END;


With this function "NVL" it should be ok
Re: oracle report problem [message #154135 is a reply to message #154014] Thu, 05 January 2006 19:50 Go to previous messageGo to next message
shatishr
Messages: 52
Registered: September 2005
Location: Shah Alam
Member
hie
ive tried it and it returns a number but the problem is in the gap it supposed to calculate 10,170,079.00 - 0.00 and the result supposed to be 10,170,079.00
in the case here its returning 9,898,560.00

why is that so ??


thanks

Re: oracle report problem [message #154136 is a reply to message #154014] Thu, 05 January 2006 20:25 Go to previous message
shatishr
Messages: 52
Registered: September 2005
Location: Shah Alam
Member
okiez i got it working...
thanks a lot bot
Previous Topic: Data load into Discoverer
Next Topic: calling report from forms
Goto Forum:
  


Current Time: Fri Nov 29 19:27:12 CST 2024