CREATE OR REPLACE function divided(var_up in varchar2,var_down in varchar2,p_sep number := 2)
return varchar2 is
temp varchar2(4000);
begin
select to_char(decode(var_down,null,0,0,0,round((var_up/var_down),p_sep)),rpad('fm999990.',9+p_sep,0)) into temp from dual;
select replace(replace('?'||to_number(temp),'?.','0.'),'?','') into temp from dual;
return temp;
end divided;
07-09
2969
02-28
3823