--Author: Venkata Potluri
--Date: Oct 21, 2015

CREATE TABLE SIEBEL_PURGE.TEMP_TXN_10212015
(
   ROW_ID         VARCHAR2 (15 CHAR) NOT NULL,
   MEMBER_ID      VARCHAR2 (15 CHAR),
   MEM_NUM        VARCHAR2 (30 CHAR),
   CREATED        DATE NOT NULL,
   PROCESS_DT     DATE,
   NUM_POINTS     NUMBER (22, 7),
   TOTAL_POINTS   NUMBER (22, 7),
   PROMO_POINTS   NUMBER (22, 7)
);

INSERT INTO SIEBEL_PURGE.TEMP_TXN_10212015 (ROW_ID,
                                            MEMBER_ID,
                                            CREATED,
                                            PROCESS_DT,
                                            NUM_POINTS)
   SELECT ROW_ID,
          MEMBER_ID,
          CREATED,
          PROCESS_DT,
          NUM_POINTS
     FROM SIEBEL.S_LOY_TXN T
    WHERE     TYPE_CD = 'Accrual'
          AND SUB_TYPE_CD = 'Cancellation'
          AND PROCESS_DT > TO_DATE ('10/18/2015', 'mm/dd/yyyy');

CREATE INDEX SIEBEL_PURGE.TEMP_TXN_10212015_F1
   ON SIEBEL_PURGE.TEMP_TXN_10212015 (ROW_ID)
   PARALLEL 12;

ALTER INDEX SIEBEL_PURGE.TEMP_TXN_10212015_F1
   NOPARALLEL;