CREATE TABLE FCT_ITEMCONTRATO_HR (
    NRITEMCONTRATO_HR       NUMBER        	NOT NULL,
    NRITEMOCONTRATO         NUMBER        	NOT NULL,
    QTITEMCONTRATO          FLOAT(126)    	NOT NULL,
    QTMEDIDACONTR           NUMBER,
    VRUNITITEMCONT          FLOAT(126)    	NOT NULL,
    VRTOTITEMCONT           FLOAT(126)    	NOT NULL,
    NRORG                   NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO                 VARCHAR2(1) 	DEFAULT 'S' NOT NULL
		CONSTRAINT CKC_IDATIVO_FCT_ITCONT_HR CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO              DATE,
    DTULTATU                DATE,
    NRORGINCLUSAO           NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'),
    CDOPERINCLUSAO          VARCHAR(12),
    NRORGULTATU             NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'),
    CDOPERULTATU            VARCHAR(12),
    IDMULTMEDVRTOT          VARCHAR2(1)   	NOT NULL,
    VRUNITITEMCONTTBLPRECO  FLOAT(126),
    QTMEDIDACALCULADA       NUMBER
)
/

ALTER TABLE FCT_ITEMCONTRATO_HR ADD CONSTRAINT PK_FCT_ITEMCONTRATO_HR PRIMARY KEY (NRITEMCONTRATO_HR)
/

CREATE INDEX SM00359_FK ON FCT_ITEMCONTRATO_HR(NRITEMOCONTRATO ASC)
/

ALTER TABLE FCT_ITEMCONTRATO_HR ADD CONSTRAINT FKSM00359ITCONTRATOHR_ITCONT
    FOREIGN KEY (NRITEMOCONTRATO) REFERENCES FCT_ITEMCONTRATO (NRITEMOCONTRATO)
/

ALTER TABLE FCT_PRORROGCONTRATO ADD DTANTDTFINAL DATE
/

ALTER TABLE FCT_PRORROGCONTRATO ADD DTANTDTINICIAL DATE
/

ALTER TABLE FCT_PRORROGCONTRATO MODIFY DTINCLUSAO DEFAULT SYSDATE
/

ALTER TABLE FCT_CONTRATOREAJUSTE ADD NRSEQPRORRCONT NUMBER
/

CREATE TABLE FCT_NEGOCIACAOCONTRATO_HR (
  NRNEGOCIACAOCONTRATO_HR NUMBER      	NOT NULL,
  NRNEGOCIACAOCONTRATO    NUMBER       	NOT NULL,
  VRTOTITEM               FLOAT(126)   	NOT NULL,
  VRPERCDESCITEM          FLOAT(126),
  VRDESCITEM              FLOAT(126),
  VRTOTITEMCOMDESC        FLOAT(126)    NOT NULL,
  NRORG                   NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO                 VARCHAR2(1) 	DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_FCT_NEGOCCONT_HR CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO              DATE,
  DTULTATU                DATE,
  NRORGINCLUSAO           NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'),
  CDOPERINCLUSAO          VARCHAR(12),
  NRORGULTATU             NUMBER		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'),
  CDOPERULTATU            VARCHAR(12),
  IDTPDESCONTO            CHAR(1)
)
/

ALTER TABLE FCT_NEGOCIACAOCONTRATO_HR ADD CONSTRAINT PK_FCT_NEGOCIACAOCONTRATO_HR PRIMARY KEY (NRNEGOCIACAOCONTRATO_HR)
/

CREATE INDEX SM00360_FK ON FCT_NEGOCIACAOCONTRATO_HR(NRNEGOCIACAOCONTRATO ASC)
/

ALTER TABLE FCT_NEGOCIACAOCONTRATO_HR ADD CONSTRAINT FKSM00360NEGCONT_HR_NEGCONT
    FOREIGN KEY (NRNEGOCIACAOCONTRATO) REFERENCES FCT_NEGOCIACAOCONTRATO (NRNEGOCIACAOCONTRATO)
/


CREATE TABLE FCT_ITNEGOCIACAOCONTRATO_HR (
  NRITNEGOCIACAOCONTRATO_HR NUMBER       	NOT NULL ,
  NRITNEGOCIACAOCONTRATO    NUMBER       	NOT NULL ,
  NRNEGOCIACAOCONTRATO      NUMBER       	NOT NULL ,
  NRITEMOCONTRATO           NUMBER,
  VRTOTITEM                 FLOAT(126)   	NOT NULL ,
  VRPERCDESCITEM            FLOAT(126),
  VRDESCITEM                FLOAT(126),
  VRTOTITEMCOMDESC          FLOAT(126)   	NOT NULL ,
  NRORG                   	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO                 	VARCHAR2(1) 	DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_FCT_ITNEGOCCONT_HR CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO              	DATE,
  DTULTATU                	DATE,
  NRORGINCLUSAO          	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'),
  CDOPERINCLUSAO          	VARCHAR(12),
  NRORGULTATU             	NUMBER		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'),
  CDOPERULTATU            	VARCHAR(12),
  NRITEMCONTRATOPAI         NUMBER,
  IDTPDESCONTO              CHAR(1)   
)
/

ALTER TABLE FCT_ITNEGOCIACAOCONTRATO_HR ADD CONSTRAINT PK_FCT_ITNEGOCIACAOCONTRATO_HR PRIMARY KEY (NRITNEGOCIACAOCONTRATO_HR)
/

CREATE INDEX SM00361_FK ON FCT_ITNEGOCIACAOCONTRATO_HR(NRITNEGOCIACAOCONTRATO ASC)
/

ALTER TABLE FCT_ITNEGOCIACAOCONTRATO_HR ADD CONSTRAINT FKSM00361ITNEGCONTHR_ITNEGCONT
    FOREIGN KEY (NRITNEGOCIACAOCONTRATO) REFERENCES FCT_ITNEGOCIACAOCONTRATO (NRITNEGOCIACAOCONTRATO)
/

CREATE TABLE FCT_PARCELANEGOCONT_HR (
  NRPARCELANEGOCONT_HR    	NUMBER        NOT NULL ,
  NRPARCELANEGOCONT       	NUMBER        NOT NULL ,
  NRNEGOCIACAOCONTRATO    	NUMBER        NOT NULL ,
  VRPARCELA               	FLOAT(126)    NOT NULL ,
  NRORG                   	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO                 	VARCHAR2(1) 	DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_FCT_PARCNEGCONT_HR CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO              	DATE,
  DTULTATU                	DATE,
  NRORGINCLUSAO          	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'),
  CDOPERINCLUSAO          	VARCHAR(12),
  NRORGULTATU             	NUMBER		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'),
  CDOPERULTATU            	VARCHAR(12),
  NRPARCELA               	NUMBER       
)
/

ALTER TABLE FCT_PARCELANEGOCONT_HR ADD CONSTRAINT PK_FCT_PARCELANEGOCONT_HR PRIMARY KEY (NRPARCELANEGOCONT_HR)
/

CREATE INDEX SM00362_FK ON FCT_PARCELANEGOCONT_HR(NRPARCELANEGOCONT ASC)
/

ALTER TABLE FCT_PARCELANEGOCONT_HR ADD CONSTRAINT FKSM00362PARCNEGHR_PARCNEGCONT
    FOREIGN KEY (NRPARCELANEGOCONT) REFERENCES FCT_PARCELANEGOCONT (NRPARCELANEGOCONT)
/