if Trunc(MONTHS_BETWEEN(to_date(to_char(sysdate, 'yyyy-MM-dd'),'yyyy-MM-dd'),to_date(substr(sfzhm,7,4)||'-'||substr(sfzhm,11,2)||'-'||substr(sfzhm,13,2), 'yyyy-MM-dd')) / 12) < 18 then
return 0;
elsif Trunc(MONTHS_BETWEEN(to_date(to_char(sysdate, 'yyyy-MM-dd'),'yyyy-MM-dd'),to_date(substr(sfzhm,7,4)||'-'||substr(sfzhm,11,2)||'-'||substr(sfzhm,13,2), 'yyyy-MM-dd')) / 12) >75 then
return 1;
else
return 2;
end if;
end;
复制代码
下面是函数调用的SQL语句:
select func_compare_sfzhm('310103200003141234') from dual;