comm.fun_getagebybirthday

create or replace function comm.fun_getagebybirthday(adt_birthday date)
return varchar2 is
s_Result varchar2(50);
begin
select case
when year_num >= 8 then
to_char(year_num) || '岁'
when year_num < 8 and year_num >= 1 then
to_char(year_num) || '岁' ||
decode(month_num, 0, '', to_char(month_num) || '个月')
when year_num < 1 then
decode(month_num, 0, '', to_char(month_num) || '个月') ||
to_char(day_num) || '天'
end
into s_Result
from (select trunc(trunc(months_between(sysdate, adt_birthday)) / 12) year_num,
mod(trunc(months_between(sysdate, adt_birthday)), 12) month_num,
trunc(sysdate -
add_months(adt_birthday,
trunc(months_between(sysdate, adt_birthday)))) day_num
from dual);
return(s_Result);

end fun_getagebybirthday;

 

上一篇:Go语言流程控制01--选择结构之if


下一篇:学习mybatis03---写映射接口与实体类