Tuesday, September 29, 2009

Create A Stop Watch with Sql

function fnc_hh_mm_ss (p_ss in number) return varchar2
is
v_ss number;
v_mm number;
v_hh number;
v_temp number;
show_hh varchar2(5);
show_mm varchar2(5);
show_ss varchar2(5);
p_show_time varchar2 (500);

begin

select decode (length(floor(floor(p_ss/60)/60)), 1 , ('0'||floor(floor(p_ss/60)/60)) , (floor(floor(p_ss/60)/60)))||':'||
decode (length(mod(floor(p_ss/60),60)) , 1 , ('0'||mod(floor(p_ss/60),60)) , (mod(floor(p_ss/60),60))) ||':'||
decode (length(mod(p_ss,60)) , 1 , ('0'||mod(p_ss,60)) , (mod(p_ss,60)))
into p_show_time
from dual;

return (p_show_time);

exception
when others then
p_show_time:='00:00:00';
return (p_show_time);
end;

No comments:

Post a Comment