CREATE TABLE FCT_ERROSAPURACAOFATURA (
  NRFATURACONT 		NUMBER 			NOT NULL,
  DSERRO       		VARCHAR2(4000) 	NOT NULL,
  CDOPERADOR   		VARCHAR2(12) 	NOT NULL,
  NRORG             NUMBER 	     	DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO           VARCHAR2(1)     DEFAULT 'S' 	NOT NULL
		CONSTRAINT CKC_IDATIVO_FCT_ERROAPURACFAT 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_ERROSAPURACAOFATURA ADD CONSTRAINT PK_FCT_ERROSAPURACAOFATURA PRIMARY KEY (NRFATURACONT, CDOPERADOR)
/

CREATE INDEX SM00338_FK ON FCT_ERROSAPURACAOFATURA (NRFATURACONT ASC)
/

ALTER TABLE FCT_ERROSAPURACAOFATURA ADD CONSTRAINT FKSM00338_ERROSAPU_FATURACONT FOREIGN KEY (NRFATURACONT) REFERENCES FCT_FATURACONT (NRFATURACONT)
/

CREATE INDEX SM00339_FK ON FCT_ERROSAPURACAOFATURA (CDOPERADOR ASC)
/

ALTER TABLE FCT_ERROSAPURACAOFATURA ADD CONSTRAINT FKSM00339_ERROSAPU_OPERADOR FOREIGN KEY (CDOPERADOR) REFERENCES OPERADOR (CDOPERADOR)
/