DECLARE
   LOG_ROW_ID   NUMBER := 0;
   ROW_COUNT    NUMBER := 0;

   CURSOR C1
   IS
      SELECT PT.PROMO_POINTS, PT.MEMBER_ID
        FROM SIEBEL_PURGE.TEMP_TXN_10212015 PT
       WHERE     PT.PROCESS_DT BETWEEN TO_DATE ('10/18/2015', 'mm/dd/yyyy')
                                   AND SYSDATE
             AND PT.PROCESS_DT IS NOT NULL
             AND PT.NUM_POINTS <> PT.TOTAL_POINTS
             AND PT.PROMO_POINTS > 0;
BEGIN
   SELECT CASE WHEN MAX (ROW_ID) IS NOT NULL THEN MAX (ROW_ID) + 1 ELSE 1 END
     INTO LOG_ROW_ID
     FROM SIEBEL_PURGE.PURGE_LOG_10012012 Z;

   INSERT INTO SIEBEL_PURGE.PURGE_LOG_10012012 (ROW_ID,
                                                PROCESS_NAME,
                                                START_TIME)
      SELECT LOG_ROW_ID, 'Update S_LOY_MEMBER', SYSDATE FROM DUAL;

   COMMIT;

   FOR ABCD IN C1
   LOOP
      UPDATE SIEBEL.S_LOY_MEMBER
         SET POINT_TYPE_E_VAL = POINT_TYPE_E_VAL + ABCD.PROMO_POINTS
       WHERE ROW_ID = ABCD.MEMBER_ID;

      ROW_COUNT := ROW_COUNT + SQL%ROWCOUNT;
      COMMIT;
   END LOOP;

   UPDATE SIEBEL_PURGE.PURGE_LOG_10012012
      SET END_TIME = SYSDATE, PROCESSED_ROWS = ROW_COUNT
    WHERE ROW_ID = LOG_ROW_ID;

   COMMIT;
END;
/

QUIT