DROP MATERIALIZED VIEW GENAPP.KPDL_MV_PETUGAS_REKAM;

CREATE MATERIALIZED VIEW GENAPP.KPDL_MV_PETUGAS_REKAM 
    (KODE_SEKSI_PEREKAM,KODE_PEG_PEREKAM,ID_KPDL_SUBJEK,KPPADM_PEREKAM,NIP_PEREKAM,
     CREATION_DATE,ORG_APPROVAL_KASI,NIP_APPROVAL_KASI,TGL_APPROVAL_KASI,STS_APPROVAL_KASI,
     TGL_APPROVAL_PKD,STS_APPROVAL_PKD)
TABLESPACE TS_KPDL
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOCACHE
NOLOGGING
NOCOMPRESS
PARALLEL ( DEGREE DEFAULT INSTANCES DEFAULT )
BUILD IMMEDIATE
REFRESH FORCE ON DEMAND
WITH PRIMARY KEY
AS 
SELECT
                                    COALESCE(a.KPP_ADM_PEREKAM, '') || '-' || COALESCE (ORG_APPROVAL_KASI,'') KODE_SEKSI_PEREKAM,
                            COALESCE(a.KPP_ADM_PEREKAM, '') || '-' || COALESCE (ORG_APPROVAL_KASI,
                                    '') || '-' || COALESCE (a.CREATED_BY,
                                    '') KODE_PEG_PEREKAM,
                                    a.ID_KPDL_SUBJEK,
                                    a.KPP_ADM_PEREKAM KPPADM_PEREKAM,
                                    a.CREATED_BY NIP_PEREKAM,
                                    a.CREATION_DATE,
                                    b.ORG_APPROVAL_KASI,
                                    b.NIP_APPROVAL_KASI,
                                    b.TGL_APPROVAL_KASI,
                                    b.STS_APPROVAL_KASI,
                                    b.TGL_APPROVAL_PKD,
                                    b.STS_APPROVAL_PKD
                                FROM
                                    KPDL_SUBJEK a
                                LEFT JOIN KPDL_TRX b ON
                                    (a.ID_KPDL_SUBJEK = b.ID_KPDL_SUBJEK)
                                WHERE
                                    a.FG_SUMBER = 'MATOA';


COMMENT ON MATERIALIZED VIEW GENAPP.KPDL_MV_PETUGAS_REKAM IS 'snapshot table for snapshot GENAPP.KPDL_MV_PETUGAS_REKAM';

CREATE INDEX GENAPP.KPDL_MV_PETUGAS_REKAM_CREATION_DATE_IDX ON GENAPP.KPDL_MV_PETUGAS_REKAM
(CREATION_DATE)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           );

CREATE INDEX GENAPP.KPDL_MV_PETUGAS_REKAM_ID_KPDL_SUBJEK_IDX ON GENAPP.KPDL_MV_PETUGAS_REKAM
(ID_KPDL_SUBJEK)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           );

CREATE INDEX GENAPP.KPDL_MV_PETUGAS_REKAM_KODE_PEG_PEREKAM_IDX ON GENAPP.KPDL_MV_PETUGAS_REKAM
(KODE_PEG_PEREKAM)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           );

CREATE INDEX GENAPP.KPDL_MV_PETUGAS_REKAM_KODE_SEKSI_PEREKAM_IDX ON GENAPP.KPDL_MV_PETUGAS_REKAM
(KODE_SEKSI_PEREKAM)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           );

CREATE INDEX GENAPP.KPDL_MV_PETUGAS_REKAM_NIP_PEREKAM_IDX ON GENAPP.KPDL_MV_PETUGAS_REKAM
(NIP_PEREKAM)
LOGGING
TABLESPACE USERS
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           );
