标签:fun exce exception 生日 date 根据 return not har
create or replace function F_GET_NL_BY_CSRQ(csrq date, v_date date)
return number
/*
* 根据出生日期和日期,计算当时的年龄
*/
as
v_yr1 char(4);
v_yr2 char(4);
begin
begin
v_yr1 := to_char(v_date,‘mmdd‘);
if csrq is not null then
v_yr2 := to_char(csrq,‘mmdd‘);
if v_yr2<=v_yr1 then
return to_number(to_char(v_date,‘yyyy‘))-to_number(to_char(csrq,‘yyyy‘));
else
return to_number(to_char(v_date,‘yyyy‘))-to_number(to_char(csrq,‘yyyy‘))-1;
end if;
else
return null;
end if;
exception
when others then
return null;
end;
end;
标签:fun exce exception 生日 date 根据 return not har
原文地址:http://www.cnblogs.com/czgxxwz/p/7700839.html