-- ================================
-- TABLE: FCT_ITNEGOCIACAOCONTRATO 
-- ================================
CREATE TABLE FCT_ITNEGOCIACAOCONTRATO (
    NRITNEGOCIACAOCONTRATO NUMBER NOT NULL,
    NRNEGOCIACAOCONTRATO   NUMBER NOT NULL,
    NRITEMOCONTRATO        NUMBER,
    NRITEMORCAMENTO        NUMBER,
    NRITEMORCAMENTOPAI     NUMBER,
    VRTOTITEM              FLOAT NOT NULL,
    VRPERCDESCITEM         FLOAT,
    VRDESCITEM             FLOAT,
    VRTOTITEMCOMDESC       FLOAT NOT NULL,
    CDSERVORCA             NUMBER,
    CDPRODFATURA           VARCHAR2(10) NOT NULL,
    NRPARCFATURA           NUMBER NOT NULL,
    NRITNEGOCIACAOPROPOSTA NUMBER,
    IDATIVO              VARCHAR2(1)  DEFAULT 'S' NOT NULL
		CONSTRAINT CKC_IDATIVO_FCT_ITNEGOCCONT    CHECK (IDATIVO IN ('S','N')),
    NRORG                NUMBER  DEFAULT   SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    DTINCLUSAO           DATE NULL,
    NRORGINCLUSAO        NUMBER DEFAULT 1 NULL,
    CDOPERINCLUSAO       VARCHAR2(12) DEFAULT '1' NULL,
    DTULTATU             DATE NULL,
    NRORGULTATU          NUMBER DEFAULT 1,
    CDOPERULTATU         VARCHAR2(12) DEFAULT '1'
)
/

ALTER TABLE FCT_ITNEGOCIACAOCONTRATO
    ADD CONSTRAINT PK_FCT_ITNEGOCCONT PRIMARY KEY (NRITNEGOCIACAOCONTRATO)
/
CREATE INDEX FKSM00237 ON "FCT_ITNEGOCIACAOCONTRATO" ("NRNEGOCIACAOCONTRATO" ASC)
/
ALTER TABLE FCT_ITNEGOCIACAOCONTRATO
    ADD CONSTRAINT FKSM00237FCT_ITNEGCONT_NEGCON FOREIGN KEY (NRNEGOCIACAOCONTRATO)
        REFERENCES FCT_NEGOCIACAOCONTRATO (NRNEGOCIACAOCONTRATO) ON DELETE CASCADE
/
CREATE INDEX FKSM00238 ON "FCT_ITNEGOCIACAOCONTRATO" ("NRITEMOCONTRATO" ASC)
/
ALTER TABLE FCT_ITNEGOCIACAOCONTRATO
    ADD CONSTRAINT FKSM00238FCT_ITNEGCONT_ITCONT FOREIGN KEY (NRITEMOCONTRATO)
        REFERENCES FCT_ITEMCONTRATO (NRITEMOCONTRATO) ON DELETE CASCADE
/
CREATE INDEX FKSM00239 ON "FCT_ITNEGOCIACAOCONTRATO" ("NRITEMORCAMENTO" ASC)
/
ALTER TABLE FCT_ITNEGOCIACAOCONTRATO
    ADD CONSTRAINT FKSM00239FCT_ITNEGCONT_ITMORC FOREIGN KEY (NRITEMORCAMENTO)
        REFERENCES FCT_ITEMORCAMENTO (NRITEMORCAMENTO)
/
CREATE INDEX FKSM00240 ON "FCT_ITNEGOCIACAOCONTRATO" ("NRITEMORCAMENTOPAI" ASC)
/
ALTER TABLE FCT_ITNEGOCIACAOCONTRATO
    ADD CONSTRAINT FKSM00240FCT_ITNGCNT_ITMORCPAI FOREIGN KEY (NRITEMORCAMENTOPAI)
        REFERENCES FCT_ITEMORCAMENTO (NRITEMORCAMENTO)
/
CREATE INDEX FKSM00241 ON "FCT_ITNEGOCIACAOCONTRATO" ("CDSERVORCA" ASC)
/
ALTER TABLE FCT_ITNEGOCIACAOCONTRATO
    ADD CONSTRAINT FKSM00241FCT_ITNEGCONT_SERVORC FOREIGN KEY (CDSERVORCA)
        REFERENCES FCT_SERVICOORCA (CDSERVORCA)
/
CREATE INDEX FKSM00242 ON "FCT_ITNEGOCIACAOCONTRATO" ("CDPRODFATURA" ASC)
/
ALTER TABLE FCT_ITNEGOCIACAOCONTRATO
    ADD CONSTRAINT FKSM00242FCT_ITNEGCONT_PROD FOREIGN KEY (CDPRODFATURA)
        REFERENCES PRODUTO (CDPRODUTO)
/
CREATE INDEX FKSM00243 ON "FCT_ITNEGOCIACAOCONTRATO" ("NRPARCFATURA" ASC)
/
ALTER TABLE FCT_ITNEGOCIACAOCONTRATO
    ADD CONSTRAINT FKSM00243FCT_ITNEGCONT_PARCNEG FOREIGN KEY (NRPARCFATURA)
        REFERENCES PARCNEGOCIO (NRPARCNEGOCIO)
/
CREATE INDEX FKSM00244 ON "FCT_ITNEGOCIACAOCONTRATO" ("NRITNEGOCIACAOPROPOSTA" ASC)
/
ALTER TABLE FCT_ITNEGOCIACAOCONTRATO
    ADD CONSTRAINT FKSM00244FCT_ITNGCONT_ITNGPRO FOREIGN KEY (NRITNEGOCIACAOPROPOSTA)
        REFERENCES FCT_ITNEGOCIACAOPROPOSTA (NRITNEGOCIACAOPROPOSTA)