declare

apply_yy      number := 0;
apply_yymmdd  number := 0;

intial_sw  number(1) := 0;
IDETIAL_NO  number := 0;

weekly_amount  number := 0;
offer_type_1_amt number := 0;
offer_type_2_amt number := 0;
offer_type_3_amt number := 0;
offer_type_4_amt number := 0;
offer_type_5_amt number := 0;
offer_type_6_amt number := 0;
offer_type_7_amt number := 0;
offer_type_8_amt number := 0;
offer_type_9_amt number := 0;
offer_type_10_amt number := 0;
offer_type_11_amt number := 0;
offer_type_12_amt number := 0;
offer_type_13_amt number := 0;
offer_type_14_amt number := 0;
offer_type_15_amt number := 0;
offer_type_16_amt number := 0;
offer_type_17_amt number := 0;
offer_type_18_amt number := 0;



begin

for c1 in  (select IAPPLY_DT,  SOFFERING_TYP, MOFFERING_AMT  from TBLOFFERDETAIL 
    where  MOFFERING_AMT  is not null 
     and   substr (IAPPLY_DT,1,6) =  ( select TO_CHAR(ADD_MONTHS(SYSDATE, -4), 'YYYYMM') from dual )  ----201602
    order by IAPPLY_DT )
    
 

  loop 
   
    IDETIAL_NO :=   IDETIAL_NO +1;

   if intial_sw  = 0 then 
       apply_yymmdd :=  c1.IAPPLY_DT;
       intial_sw  := 1; 
   end if;
       
  IF  apply_yymmdd =  c1.IAPPLY_DT then 
        weekly_amount :=  weekly_amount + c1.MOFFERING_AMT;
   IF  c1.SOFFERING_TYP = '1' then 
        offer_type_1_amt := offer_type_1_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '2' then 
            offer_type_2_amt := offer_type_2_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '3' then 
            offer_type_3_amt := offer_type_3_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '4' then 
            offer_type_4_amt := offer_type_4_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '5' then 
            offer_type_5_amt := offer_type_5_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '6' then 
            offer_type_6_amt := offer_type_6_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '7' then 
            offer_type_7_amt := offer_type_7_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '8' then 
            offer_type_8_amt := offer_type_8_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '9' then 
            offer_type_9_amt := offer_type_9_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '10' then 
            offer_type_10_amt := offer_type_10_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '11' then 
            offer_type_11_amt := offer_type_11_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '12' then 
            offer_type_12_amt := offer_type_12_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '13' then 
            offer_type_13_amt := offer_type_13_amt + c1.MOFFERING_AMT;
     elsif  c1.SOFFERING_TYP = '14' then 
            offer_type_14_amt := offer_type_14_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '15' then 
            offer_type_15_amt := offer_type_15_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '16' then 
            offer_type_16_amt := offer_type_16_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '17' then 
            offer_type_17_amt := offer_type_17_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '18' then 
           offer_type_18_amt := offer_type_18_amt + c1.MOFFERING_AMT;
    else offer_type_18_amt := offer_type_18_amt + c1.MOFFERING_AMT;
    end if; 
 
ELSE
        apply_yy := substr(apply_yymmdd,1,4);

if weekly_amount != 0 then 
 INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES (  apply_yy  , 'IDON01WK99' ,  99,  weekly_amount , 'WEEKLY Total',    apply_yymmdd, IDETIAL_NO );
end if; 
if   offer_type_1_amt  != 0 then 
  INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES  (  apply_yy  , 'IDON01WK1' ,  1,  offer_type_1_amt , 'WEEKLY Tithes',    apply_yymmdd, IDETIAL_NO );
end if;
if   offer_type_2_amt != 0 then 
 INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK2' ,  2,   offer_type_2_amt , 'WEEKLY Thanks',    apply_yymmdd, IDETIAL_NO );
end if;
if   offer_type_3_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK3' ,  3,   offer_type_3_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_4_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK4' ,  4,   offer_type_4_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_5_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK5' ,  5,   offer_type_5_amt , 'WEEKLY SpecialFirm',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_6_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK6' ,  6,   offer_type_6_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_7_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK7' ,  7,   offer_type_7_amt , 'WEEKLY Steward',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_8_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK3' ,  8,   offer_type_8_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_9_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK9' ,  9,   offer_type_9_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_10_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK10' ,  10,   offer_type_10_amt , 'WEEKLY Retreat',    apply_yymmdd, IDETIAL_NO );
 end if;

if   offer_type_11_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK3' ,  11,   offer_type_11_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;
if   offer_type_12_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK12' ,  12,   offer_type_12_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_13_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK13' ,  13,   offer_type_13_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

 if  offer_type_14_amt != 0 then 
 INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK14' ,  14,   offer_type_14_amt , 'WEEKLY Five_Two',    apply_yymmdd, IDETIAL_NO );
end if;
if offer_type_15_amt != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK15' ,  15,   offer_type_15_amt , 'WEEKLY Post Offering',    apply_yymmdd, IDETIAL_NO );     
end if;
if offer_type_16_amt != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK16' ,  16,   offer_type_16_amt , 'WEEKLY EM',    apply_yymmdd, IDETIAL_NO );
end if;
if offer_type_17_amt != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK17' ,  17,   offer_type_17_amt , 'WEEKLY Elder',    apply_yymmdd, IDETIAL_NO );
 end if;
 if offer_type_18_amt != 0 then 
 INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK18' ,  18,   offer_type_18_amt , 'WEEKLY Thousand',    apply_yymmdd, IDETIAL_NO );
END IF;     

     apply_yymmdd :=  c1.IAPPLY_DT ;
       
       IDETIAL_NO := 0;

       weekly_amount  := 0;
       offer_type_1_amt  := 0;
       offer_type_2_amt  := 0;
       offer_type_3_amt  := 0;
       offer_type_4_amt  := 0;
       offer_type_5_amt  := 0;
       offer_type_6_amt  := 0;

       offer_type_7_amt  := 0;
       offer_type_8_amt  := 0;
       offer_type_9_amt  := 0;

       offer_type_10_amt  := 0;
       offer_type_11_amt  := 0;
       offer_type_12_amt  := 0;
       offer_type_13_amt  := 0;
 
       offer_type_14_amt  := 0;
       offer_type_15_amt  := 0;
       offer_type_16_amt  := 0;
       offer_type_17_amt  := 0;
	offer_type_18_amt  := 0;

     weekly_amount :=  weekly_amount + c1.MOFFERING_AMT;

  IF  c1.SOFFERING_TYP = '1' then 
        offer_type_1_amt := offer_type_1_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '2' then 
            offer_type_2_amt := offer_type_2_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '3' then 
            offer_type_3_amt := offer_type_3_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '4' then 
            offer_type_4_amt := offer_type_4_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '5' then 
            offer_type_5_amt := offer_type_5_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '6' then 
            offer_type_6_amt := offer_type_6_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '7' then 
            offer_type_7_amt := offer_type_7_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '8' then 
            offer_type_8_amt := offer_type_8_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '9' then 
            offer_type_9_amt := offer_type_9_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '10' then 
            offer_type_10_amt := offer_type_10_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '11' then 
            offer_type_11_amt := offer_type_11_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '12' then 
            offer_type_12_amt := offer_type_12_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '13' then 
            offer_type_13_amt := offer_type_13_amt + c1.MOFFERING_AMT;
     elsif  c1.SOFFERING_TYP = '14' then 
            offer_type_14_amt := offer_type_14_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '15' then 
            offer_type_15_amt := offer_type_15_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '16' then 
            offer_type_16_amt := offer_type_16_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '17' then 
            offer_type_17_amt := offer_type_17_amt + c1.MOFFERING_AMT;
    elsif  c1.SOFFERING_TYP = '18' then 
           offer_type_18_amt := offer_type_18_amt + c1.MOFFERING_AMT;
    else offer_type_18_amt := offer_type_18_amt + c1.MOFFERING_AMT;
    end if; 

END IF; 
end loop;

apply_yy:= substr(apply_yymmdd,1,4);

if weekly_amount != 0 then 
 INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES (  apply_yy  , 'IDON01WK99' ,  99,  weekly_amount , 'WEEKLY Total',    apply_yymmdd, IDETIAL_NO );
end if; 
if   offer_type_1_amt  != 0 then 
  INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES  (  apply_yy  , 'IDON01WK1' ,  1,  offer_type_1_amt , 'WEEKLY Tithes',    apply_yymmdd, IDETIAL_NO );
end if;
if   offer_type_2_amt != 0 then 
 INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK2' ,  2,   offer_type_2_amt , 'WEEKLY Thanks',    apply_yymmdd, IDETIAL_NO );
end if;
if   offer_type_3_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK3' ,  3,   offer_type_3_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_4_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK4' ,  4,   offer_type_4_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_5_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK5' ,  5,   offer_type_5_amt , 'WEEKLY SpecialFirm',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_6_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK6' ,  6,   offer_type_6_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_7_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK7' ,  7,   offer_type_7_amt , 'WEEKLY Steward',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_8_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK3' ,  8,   offer_type_8_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_9_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK9' ,  9,   offer_type_9_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_10_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK10' ,  10,   offer_type_10_amt , 'WEEKLY Retreat',    apply_yymmdd, IDETIAL_NO );
 end if;

if   offer_type_11_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK3' ,  11,   offer_type_11_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;
if   offer_type_12_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK12' ,  12,   offer_type_12_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

if   offer_type_13_amt  != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK, SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
         VALUES ( apply_yy, 'IDON01WK13' ,  13,   offer_type_13_amt , 'WEEKLY General',    apply_yymmdd, IDETIAL_NO );
end if;

 if  offer_type_14_amt != 0 then 
 INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK14' ,  14,   offer_type_14_amt , 'WEEKLY Five_Two',    apply_yymmdd, IDETIAL_NO );
end if;
if offer_type_15_amt != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK15' ,  15,   offer_type_15_amt , 'WEEKLY Post Offering',    apply_yymmdd, IDETIAL_NO );     
end if;
if offer_type_16_amt != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK16' ,  16,   offer_type_16_amt , 'WEEKLY EM',    apply_yymmdd, IDETIAL_NO );
end if;
if offer_type_17_amt != 0 then 
INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK17' ,  17,   offer_type_17_amt , 'WEEKLY Elder',    apply_yymmdd, IDETIAL_NO );
 end if;
 if offer_type_18_amt != 0 then 
 INSERT INTO TBLTRANSHISTORY 
      (IPROGRAMTYPE_SK,  SINCOME_PAYTYPE_ID,  SNATIVE_NM,  MTRANS_AMT, SDISCRIPTION,  IAPPLY_DT,  SEQUENCE_NO)
   VALUES   ( apply_yy, 'IDON01WK18' ,  18,   offer_type_18_amt , 'WEEKLY Thousand',    apply_yymmdd, IDETIAL_NO );
END IF;       

/*
    <td  align="center" 
          style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 42px; PADDING-LEFT: 35px; PADDING-RIGHT: 
        10px; FONT-FAMILY:  Arial, Helvetica, sans-serif; COLOR: #0085c3; FONT-SIZE: 29px; PADDING-TOP: 0px" 
          class="style1">
               Weekly Auto Donation Created....</td> ' ;

*/
    commit;
    end;