Function return without value
303302Mar 19 2004 — edited Mar 19 2004Hello, I have made a function called get_avg_alf5 which is supposed to return the ratio sum_avg_alf3/sum_dato. However , my problem is that the function returns 'ORA-06503: PL/SQL: Function returned without value' when testing. I have put in some DBMS_OUTPUT.PUT_LINE and both sum_avg_alf3 and sum_dato contain values. Can someone help with this issue?
Regards
Roar
function get_avg_alf5(cur_navn varchar2, start_dato date, slutt_dato date )
return number
IS
cell c.cell_id%type;
alder_cell a_day.cell_age%type;
avg_alf3 number(4,1);
snitt_verdi_slutt number(5,1);
sum_avg_alf3 number(5,1):= 0;
antall_dato number (4,1);
sum_dato number (4,1):= 0;
CURSOR celler_alder IS
select distinct(cell_id) celler
from celd
where pot_id = cur_navn and sec_id not in ('G1','H1');
BEGIN
for teller in celler_alder LOOP
select sum(avg(ca.alf3))
into avg_alf3
from cel_an ca, ag_day ad
where ca.cell_id = ad.device_id and trunc(ca.date_time) = ad.date_time and
ca.cell_id = teller.celler and ad.cell_age > 60 and ca.date_time between start_dato and
slutt_dato
group by ad.ce_age;
if avg_alf3 is null then
sum_avg_alf3:= sum_avg_alf3;
else
sum_avg_alf3:= sum_avg_alf3 + avg_alf3;
end if;
DBMS_OUTPUT.PUT_LINE(Sum alf ||sum_avg_alf3);
select count(distinct(ad.cell_age))
into antall_dato
from cel_an ca,ag_day ad
where ca.cell_id = ad.device_id and trunc (ca.date_time) = ad.date_time and
ca.cell_id = teller.celler and ad.cell_age > 60 and ca.date_time between start_dato and slutt_dato;
sum_dato:= sum_dato + antall_dato;
DBMS_OUTPUT.PUT_LINE(Sum date || sum_dato);
end loop;
snitt_verdi_slutt := round(trunc(sum_avg_alf3/sum_dato,3),1);
return (snitt_verdi_slutt);
end;