ALTER TABLE HISTLOGCOMPCARD ADD DSRDMUSU VARCHAR2(50) NULL
/
ALTER TABLE HISTLOGCOMPCARD ADD DSENDUSU VARCHAR2(50) NULL
/
ALTER TABLE HISTLOGCOMPCARD ADD DSNMUSU VARCHAR2(50) NULL
/
ALTER TABLE HISTLOGCOMPCARD ADD DSMETODO VARCHAR2(250) NULL
/
ALTER TABLE HISTLOGCOMPCARD ADD VRPECONSCARDANT FLOAT NULL
/
ALTER TABLE HISTLOGCOMPCARD ADD VRPECONSCARDATU FLOAT NULL
/
ALTER TABLE HISTLOGCOMPCARD ADD NRCARDAPIO VARCHAR2(10) NULL
/
ALTER TABLE HISTLOGCOMPCARD ADD NRSEQPRATCAR NUMBER(3) NULL
/

CREATE INDEX IDX_HISTLOGCOMPCARD_01 ON HISTLOGCOMPCARD(DTMESCARD, CDSERVFILI, CDFILIAL)
/


CREATE TABLE HISTLOGCARDADIA
(
    CDFILIAL          VARCHAR2(4) NOT NULL,
    CDSERVFILI        VARCHAR2(5) NOT NULL,
    DTMESCARD         DATE NOT NULL, 
    DTCARDAPIO        DATE NOT NULL,
    NRCARDAPIO        VARCHAR2(10) NOT NULL,
    CDOPERADOR        VARCHAR2(12) NULL,
    DTALTERACAO       DATE NULL,
    IDOPERACAO		  VARCHAR2(1) NULL,
    QTCOMESTICARANT   FLOAT NULL,
    QTCOMESTICARATU   FLOAT NULL,
    QTCLIESTICARANT   FLOAT NULL,
    QTCLIESTICARATU   FLOAT NULL,
    QTFUNESTICARANT   FLOAT NULL,
    QTFUNESTICARATU   FLOAT NULL,
    QTDOAESTICARANT   FLOAT NULL,
    QTDOAESTICARATU   FLOAT NULL,
    QTCOMEFETCARANT   FLOAT NULL,
    QTCOMEFETCARATU   FLOAT NULL,
    QTCLIEFETCARANT   FLOAT NULL,
    QTCLIEFETCARATU   FLOAT NULL,
    QTFUNEFETCARANT   FLOAT NULL,
    QTFUNEFETCARATU   FLOAT NULL,
    QTDOAEFETCARANT   FLOAT NULL,
    QTDOAEFETCARATU   FLOAT NULL,
    QTESTITURNO1ANT   FLOAT NULL,
    QTESTITURNO1ATU   FLOAT NULL,
    QTESTITURNO2ANT   FLOAT NULL,
    QTESTITURNO2ATU   FLOAT NULL,
    QTESTITURNO3ANT   FLOAT NULL,
    QTESTITURNO3ATU   FLOAT NULL,
    QTESTITURNO4ANT   FLOAT NULL,
    QTESTITURNO4ATU   FLOAT NULL,
    DSRDMUSU 		  VARCHAR2(50) NULL,
    DSENDUSU 		  VARCHAR2(50) NULL,
    DSNMUSU 		  VARCHAR2(50) NULL,
    DSMETODO 		  VARCHAR2(250) NULL,
    NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
	CONSTRAINT CKC_IDATIVO_HISTLOGCARDADIA CHECK (IDATIVO IN ('S','N'))
)
/

CREATE INDEX IDX_HISTLOGCARDADIA_01 ON HISTLOGCARDADIA(DTMESCARD, CDFILIAL, CDSERVFILI)
/

CREATE TABLE HISTLOGCNFCAMES
(
    CDFILIAL 		   VARCHAR2(4) NOT NULL,
    CDSERVFILI		   VARCHAR2(5) NOT NULL,
    DTMESCARD		   DATE NOT NULL,
    NRSEQCNFMES		   NUMBER(3) NOT NULL,
    CDTIPOPRAT		   VARCHAR2(2) NOT NULL,
    CDOPERADOR		   VARCHAR2(12) NULL,
    DTALTERACAO		   DATE NULL,
    IDOPERACAO		   VARCHAR2(1) NULL,
    IDOPCCNFMESANT 	   VARCHAR2(1) NULL,  
    IDOPCCNFMESATU 	   VARCHAR2(1) NULL,  
    IDIMPCNFMESANT	   VARCHAR2(1) NULL,
    IDIMPCNFMESATU	   VARCHAR2(1) NULL,
    IDCONCNFMESANT 	   CHAR(1) NULL,
    IDCONCNFMESATU 	   CHAR(1) NULL,
    IDRESERVAMYMENUANT VARCHAR2(1) NULL,
    IDRESERVAMYMENUATU VARCHAR2(1) NULL,
    NRORDCNFMESANT    NUMBER(15) NULL,
    NRORDCNFMESATU 	  NUMBER(15) NULL,
    DSCOMPLTPMESANT   VARCHAR2(15) NULL,
    DSCOMPLTPMESATU   VARCHAR2(15) NULL,
    DSRDMUSU		  VARCHAR2(50) NULL,
    DSENDUSU 		  VARCHAR2(50) NULL,
    DSNMUSU 		  VARCHAR2(50) NULL,
    DSMETODO 		  VARCHAR2(250) NULL,
    NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
	CONSTRAINT CKC_IDATIVO_HISTLOGCNFCAMES CHECK (IDATIVO IN ('S','N'))
)
/

CREATE INDEX IDX_HISTLOGCNFCAMES_01 ON HISTLOGCNFCAMES(DTMESCARD, CDFILIAL, CDSERVFILI)
/

CREATE TABLE HISTLOGCARDAMES
(
    CDFILIAL 		 VARCHAR2(4) NULL,
    CDSERVFILI 		 VARCHAR2(5) NULL,
    DTMESCARD 		 DATE NULL,
    CDOPERADOR		 VARCHAR2(12) NULL,
    DTALTERACAO		 DATE NULL,
    IDOPERACAO		 VARCHAR2(1) NULL,
    DTREFECUSTMESANT DATE NULL,
    DTREFECUSTMESATU DATE NULL,
    DTREFECUSTRECANT DATE NULL,
    DTREFECUSTRECATU DATE NULL,
    IDCARDLIBCENTANT VARCHAR2(1) NULL,
    IDCARDLIBCENTATU VARCHAR2(1) NULL,
    IDCARDLIBAGREANT VARCHAR2(1) NULL,
    IDCARDLIBAGREATU VARCHAR2(1) NULL,
    CDCARDCICLOANT   VARCHAR2(5) NULL,
    CDCARDCICLOATU 	 VARCHAR2(5) NULL,
    CDOPERVALIDACAOANT VARCHAR2(12) NULL,
    CDOPERVALIDACAOATU VARCHAR2(12) NULL,
    DTVALIDACAOANT    DATE NULL,
    DTVALIDACAOATU    DATE NULL,
    IDVALIDADOANT  	  VARCHAR2(1) NULL,
    IDVALIDADOATU	  VARCHAR2(1) NULL,
    DSRDMUSU		  VARCHAR2(50) NULL,
    DSENDUSU 		  VARCHAR2(50) NULL,
    DSNMUSU			  VARCHAR2(50) NULL,
    DSMETODO 		  VARCHAR2(250) NULL,
    NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
		CONSTRAINT CKC_IDATIVO_HISTLOGCARDAMES CHECK (IDATIVO IN ('S','N'))
)
/

CREATE INDEX IDX_HISTLOGCARDAMES_01 ON HISTLOGCARDAMES(DTMESCARD, CDFILIAL, CDSERVFILI)
/

