ALTER TABLE TIPOOPERAC ADD IDBLOQNFFORAMES VARCHAR2(01)
/

CREATE TABLE LANCNFFORAMES(
   NRLANCNFFORAMES 	  VARCHAR2(10) NOT NULL,
   CDFILIAL 		  VARCHAR2(04) NOT NULL,  
   CDEMPRESA 		  VARCHAR2(02) NOT NULL,
   CDINSCESTA 		  VARCHAR2(16) NOT NULL, 
   NRINSJURIEST 	  VARCHAR2(20) NOT NULL,
   IDENTRSAIDOP 	  VARCHAR2(01) NOT NULL,
   CDTIPOOPER 		  VARCHAR2(02) NOT NULL,  
   CDEMISSORNF 	  	  VARCHAR2(21) NOT NULL,
   CDMODDOCFISC 	  VARCHAR2(02) NOT NULL,  
   CDSERIE 			  VARCHAR2(05) NOT NULL, 
   DTEMISSAO 		  DATE 		   NOT NULL,
   NRNOTAFISC 		  VARCHAR2(20) NOT NULL,
   VRNOTAFISC 		  FLOAT 	   NOT NULL,
   CDOPERADOR 		  VARCHAR2(12) NOT NULL, 
   DTTENTATIVALANC 	  DATE NOT NULL,
   DTAUTORIZALANC 	  DATE NULL,
   DTEFETIVALANC 	  DATE NULL,
   DSOBSAUTORIZA 	  VARCHAR2(4000),
   IDSTATUS 		  VARCHAR2(01)	  DEFAULT 'P' NOT 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_LANCNFFORAMES CHECK (IDATIVO IN ('S','N')),
	   CONSTRAINT FKFIS00909INSCRESTAD FOREIGN KEY (CDEMPRESA, CDINSCESTA) REFERENCES INSCRESTAD (CDEMPRESA, CDINSCESTA),
	   CONSTRAINT FKFIS00910TIPOOPERAC FOREIGN KEY (IDENTRSAIDOP, CDTIPOOPER) REFERENCES TIPOOPERAC (IDENTRSAIDOP, CDTIPOOPER),
	   CONSTRAINT FKFIS00911MODDOCFISC FOREIGN KEY (CDMODDOCFISC) REFERENCES MODDOCFISC (CDMODDOCFISC),
	   CONSTRAINT FKFIS00912FILIAL FOREIGN KEY (CDFILIAL) REFERENCES FILIAL (CDFILIAL),
	   CONSTRAINT CKC_IDSTATUS_LANCNFFORAMES CHECK (IDSTATUS IN ('A', 'P')),
	   CONSTRAINT FKFIS00913OPERADOR FOREIGN KEY (CDOPERADOR) REFERENCES OPERADOR (CDOPERADOR),
	   CONSTRAINT FKFIS00914SERIEENTR FOREIGN KEY (CDSERIE) REFERENCES SERIEENTR (CDSERIEENTR)
)
/

CREATE INDEX FIS00909_FK ON LANCNFFORAMES (CDEMPRESA ASC, CDINSCESTA ASC)
/

CREATE INDEX FIS00910_FK ON LANCNFFORAMES (IDENTRSAIDOP ASC, CDTIPOOPER ASC)
/

CREATE INDEX FIS00911_FK ON LANCNFFORAMES (CDMODDOCFISC ASC)
/

CREATE INDEX FIS00912_FK ON LANCNFFORAMES (CDFILIAL ASC)
/

CREATE INDEX FIS00913_FK ON LANCNFFORAMES (CDOPERADOR ASC)
/

CREATE INDEX FIS00914_FK ON LANCNFFORAMES (CDSERIE)
/
