CREATE TABLE FCT_VARPRECBASESERVORCA
(
    NRVARPRECBASESERVORCA  		NUMBER 							NOT NULL,
    NRSEQORCAMENTO         		NUMBER 							NOT NULL,
    CDSERVORCA             		NUMBER 							NOT NULL,
    CDTPMEDIDASERV         		NUMBER 							NOT NULL,
    CDTPMEDIDAVARIAVEL     		NUMBER,
    QTMEDIDAINIVARIACAO    		NUMBER,
    QTMEDIDAFIMVARIACAO    		NUMBER,
    QTFRANQUIA             		NUMBER,
    VRPRECOVARIACAO        		NUMBER,
    IDMULTIPVARIACAO       		CHAR(1),
    NRORG                  		NUMBER          DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO                		VARCHAR2(1)     DEFAULT 'S' 	NOT NULL
      CONSTRAINT CKC_IDATIVO_FCT_VRPREBASESRV CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO             		DATE                       		NULL,
    DTULTATU               		DATE                       		NULL,
    NRORGINCLUSAO          		NUMBER          DEFAULT 1   	NULL,
    CDOPERINCLUSAO         		VARCHAR2(12)    DEFAULT '1' 	NULL,
    NRORGULTATU            		NUMBER          DEFAULT 1   	NULL,
    CDOPERULTATU           		VARCHAR2(12)    DEFAULT '1'
)
/
ALTER TABLE FCT_VARPRECBASESERVORCA ADD CONSTRAINT PK_VARPRECBASESERVORCA PRIMARY KEY(NRVARPRECBASESERVORCA)
/
ALTER TABLE FCT_VARPRECBASESERVORCA ADD CONSTRAINT CK_VARPRECSERVORCA_IDMULTIVAR CHECK(IDMULTIPVARIACAO IN ('S', 'N'))
/
ALTER TABLE FCT_VARPRECBASESERVORCA ADD CONSTRAINT FKSM00188ORCA_VARPRECBASE FOREIGN KEY (NRSEQORCAMENTO)
   REFERENCES FCT_ORCAMENTO(NRSEQORCAMENTO) ON DELETE CASCADE
/
ALTER TABLE FCT_VARPRECBASESERVORCA ADD CONSTRAINT FCT_SERV_VARPRECBASE FOREIGN KEY (CDSERVORCA)
  REFERENCES FCT_SERVICOORCA(CDSERVORCA)
/
ALTER TABLE FCT_VARPRECBASESERVORCA ADD CONSTRAINT FKSM00189TPMEDSERV_VARPRECBASE FOREIGN KEY (CDTPMEDIDASERV)
  REFERENCES FCT_TIPOMEDIDASERV(CDTPMEDIDASERV)
/
ALTER TABLE FCT_VARPRECBASESERVORCA ADD CONSTRAINT FKSM00190TPMEDVAR_VARPRECBASE FOREIGN KEY (CDTPMEDIDAVARIAVEL)
  REFERENCES FCT_TIPOMEDIDASERV(CDTPMEDIDASERV)
/
ALTER TABLE FCT_ITEMORCAMENTO ADD IDELEMENTO VARCHAR2(100) NULL
