ITPub博客

首页 > 数据治理 > 数据治理 > 计算退休日期

计算退休日期

原创 数据治理 作者:degann 时间:2025-03-14 14:33:20 1 删除 编辑

create or replace function get_retirement_date(v_birthday date, v_type integer) return date is

  p_interval     integer; --确定是2个月或4个月延一个月

  p_change_date   date := to_date('2025-01-01', 'YYYY-MM-DD'); --调整开始日

  p_old_end_date   date; --调整前的退休日子

  p_new_end_date   date; --调整后的最大退休日子

  p_new_calc_date date; --调整后的计算出的退休日子

  p_new_months   integer; --调整后的最大退休月数


begin


  case v_type --55,58,63 三种类型

    when 55 then

      begin

        p_old_end_date := add_months(v_birthday, 50 * 12);

        p_new_months := 55 * 12;

        p_new_end_date := add_months(v_birthday, p_new_months);

        p_interval   := 2;

      end;

    when 58 then

      begin

        p_old_end_date := add_months(v_birthday, 55 * 12);

        p_new_months := 58 * 12;

        p_new_end_date := add_months(v_birthday, p_new_months);

        p_interval   := 4;

      end;

    when 63 then

      begin

        p_old_end_date := add_months(v_birthday, 60 * 12);

        p_new_months := 63 * 12;

        p_new_end_date := add_months(v_birthday, p_new_months);

        p_interval   := 4;

      end;

  end case;


  if p_old_end_date < p_change_date then --在调整政策日期前就退休了

         p_new_calc_date := p_old_end_date;

  else

    select case

             when months_between(add_months(p_old_end_date,

                                     months_between(p_old_end_date, p_change_date) / p_interval), v_birthday) < p_new_months 

             then--计算出的退休日期小于新的最大退休日期时,取计算出的

                    add_months(p_old_end_date, months_between(p_old_end_date, p_change_date) / p_interval)

             else

                    p_new_end_date

           end into p_new_calc_date

      from dual;

  end if;


  return(p_new_calc_date);


end;


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/20595227/viewspace-3077686/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2019-04-11

  • 博文量
    1
  • 访问量
    1183