`

通过LASJ和FASJ算LALX

阅读更多

工作备份,留以后用.

 

FAXJSX=FASJ

PASJ可以改为LASJ,效果是一样的.

create or replace function sjsb.GetLAZL (FAXJSX in varchar2,PASJ in varchar2)

Return Varchar2 is

  V_LAZL_CODE VARCHAR2(60);

  GiapBMonth VARCHAR2(6);

  GiapEMonth VARCHAR2(6);

  fasjsx1 varchar2(8);

  PASJ1 varchar2(8);

begin

  V_LAZL_CODE:='';

  fasjsx1:=substr(FAXJSX,1,8);

  PASJ1:=substr(PASJ,1,8);

     if FAXJSX is not null and PASJ is not null then

       if substr(FAXJSX,7,2)>'20' then

         GiapBMonth := to_char(add_months(to_date(fasjsx1,'yyyymmdd'),1),'yyyymm');

       else

         GiapBMonth :=substr(FAXJSX,1,6);

       end if;

       if substr(PASJ,7,2)>'20' then

           GiapEMonth := to_char(add_months(to_date(PASJ1,'yyyymmdd'),1),'yyyymm');

       else

         GiapEMonth :=substr(PASJ,1,6);

       end if;

 

       if substr(GiapEMonth,1,4)-substr(GiapBMonth,1,4)>0 then

         V_LAZL_CODE:='3';

       else

         if GiapEMonth > GiapBMonth then

           V_LAZL_CODE:='2';

         else

           V_LAZL_CODE:='1';

         end if;

       end if;

     end if;

  return V_LAZL_CODE;

end GetLAZL;

0
5
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics