Oracle_FUNCTION ——gettwtax

CREATE OR REPLACE FUNCTION gettwtax
(
       P_SALARY IN NUMBER,
       P_PSNNUM 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 decode(P_PSNNUM,
                          0,hr_twtax.num0,
                          1,hr_twtax.num1,
                          2,hr_twtax.num2,
                          3,hr_twtax.num3,
                          4,hr_twtax.num4,
                          5,hr_twtax.num5,
                          6,hr_twtax.num6,
                          7,hr_twtax.num7,
                          8,hr_twtax.num8,
                          9,hr_twtax.num9,
                          10,hr_twtax.num10,
                          11,hr_twtax.num11,
                          0.00 ) into result
              from hr_twtax
             where hr_twtax.startsalary  <= P_SALARY
               and hr_twtax.endsalary >= P_SALARY
               and hr_twtax.pk_org = (select pk_org from org_orgs where code = P_PK_ORG and nvl(dr,0)=0 and rownum = 1)
               and rownum = 1
               and nvl(hr_twtax.dr,0)=0;
      result := nvl(result,0.00);
  else
    result := 0.00;
  end if;
  RETURN result;
END;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章