Oracle_FUNCTION——gettwhealthins

CREATE OR REPLACE FUNCTION gettwhealthins
(
       P_SALARY IN NUMBER,
       P_PSNNUM IN NUMBER,
       P_PSNTYPE IN NUMBER,
       P_MTYPE IN NUMBER,
       P_PK_ORG IN CHAR
)
RETURN VARCHAR2 IS result NUMBER(31,8);
BEGIN
  result := 0.00;
  if(P_SALARY > 0.00) then
            select nvl(tempnum,0.00) into result from (
            SELECT decode(P_MTYPE,
                         0, hr_twhealthins.monthins,
                         1, decode(P_PSNNUM,
                                   0, hr_twhealthins.family0,
                                   1, hr_twhealthins.family1,
                                   2, hr_twhealthins.family2,
                                   3, hr_twhealthins.family3,
                                   4, hr_twhealthins.family4,
                                   5, hr_twhealthins.family5),
                         2, hr_twhealthins.subsidy,
                         3, hr_twhealthins.amountins) tempnum
              from hr_twhealthins
             where hr_twhealthins.type = P_PSNTYPE
               and hr_twhealthins.pk_org = (select pk_org from org_orgs where code = P_PK_ORG and nvl(dr,0)=0 and rownum = 1)
               and nvl(hr_twhealthins.dr, 0) = 0
          
          -- 按最小绝对值方式    
          --order by abs(monthins-P_SALARY) asc, monthins desc) temp where rownum = 1;
          
          -- 按大于等于薪资的最小值方式
               and monthins >= P_SALARY 
          order by monthins asc) temp where rownum = 1;
  else
    result := 0.00;
  end if;
  RETURN result;
END;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值