DECLARE
i NUMBER;
BEGIN
FOR i IN 1..12 LOOP
UPDATE TRANSFER
SET
CONTRIBUTIONS =
(Select SUM(AMOUNT) from CONTRIBUTION
where UPPER(MISSIONARY_ID) = UPPER(:P35_MISSIONARY_ID)
AND to_number(to_char(CONTRIBUTION_DATE,'MM')) = i
AND :P35_YEAR = to_number(to_char(CONTRIBUTION_DATE,'YYYY'))),
DEDUCTIONS = (Select SUM(AMOUNT*DTPERCENT/100) from DEDUCTION_RESULT,DEDUCTION_TYPE where UPPER(MISSIONARY_ID) = UPPER(:P35_MISSIONARY_ID)AND MONTH = i AND NVL(DEDUCTION,0) = DTID),
EXPENSES =(Select (REGIONAL_FUND+PENSION+MISSIONARY_KEEP+PERSONAL+PAYPAL+WIRE_FEE+OTHERS) from EXPENSES where UPPER(MISSIONARY_ID) = UPPER(:P35_MISSIONARY_ID) AND MONTH = i)
WHERE MONTH = i;
END LOOP;
COMMIT;
END;