CREATE TABLE ITEMORCAPROD_FCT_ITEMORCAMENTO (
	ID             NUMBER(10) NOT NULL,
	CDSERVORCA     NUMBER(10) NOT NULL,
	CDITORCAPROD   VARCHAR2(3) NOT NULL,
	NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ITORCPRD_FCT_ITORC CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO        DATE                  			NULL,
    DTULTATU          DATE                  			NULL,
    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'
)
/

ALTER TABLE ITEMORCAPROD_FCT_ITEMORCAMENTO ADD CONSTRAINT PK_ITEMORCA_ID PRIMARY KEY (ID)
/

CREATE INDEX SM00296_FK ON ITEMORCAPROD_FCT_ITEMORCAMENTO (CDITORCAPROD ASC)
/

ALTER TABLE ITEMORCAPROD_FCT_ITEMORCAMENTO ADD CONSTRAINT FKSM00296ITEMORCA_CDITORCAPROD
	FOREIGN KEY (CDITORCAPROD) REFERENCES ITEMORCAPROD (CDITORCAPROD)
/

CREATE INDEX SM00297_FK ON ITEMORCAPROD_FCT_ITEMORCAMENTO (CDSERVORCA ASC)
/

ALTER TABLE ITEMORCAPROD_FCT_ITEMORCAMENTO ADD CONSTRAINT FKSM00297ITEMORCA_CDSERVORCA
	FOREIGN KEY (CDSERVORCA) REFERENCES FCT_SERVICOORCA (CDSERVORCA)
/

ALTER TABLE ITEMORCAPROD_FCT_ITEMORCAMENTO ADD CONSTRAINT CK_ITEMORCA_IDATIVO CHECK(IDATIVO IN ('S', 'N'))
/

ALTER TABLE FCT_ORCAMENTO ADD NRSOLISERV VARCHAR2(10)
/

CREATE TABLE FCT_LOGALTCNPJPARCEIRO ( 
	NRALTCNPJPARCEIRO  NUMBER,
	NROLDINSCRICAO     VARCHAR2(20),
	NRNEWINSCRICAO     VARCHAR2(20),
	DTALTCNPJPARCEIRO  DATE,
	DSJUSTIFICATIVA    VARCHAR2(4000),
	NMARQUIVO          VARCHAR2(300),
	DSCAMINHOARQ       VARCHAR2(500),
	DSTIPO             VARCHAR2(150),
	VRTAMANHO          FLOAT(126),
	NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_FCT_LOGALTCNPJPARC CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO        DATE                  			NULL,
    DTULTATU          DATE                  			NULL,
    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'
)
/

ALTER TABLE FCT_LOGALTCNPJPARCEIRO ADD CONSTRAINT PK_LOGALTCNPJPARCEIRO PRIMARY KEY (NRALTCNPJPARCEIRO)
/