CREATE TABLE IMPLANTSALDCOME (
  CDEMPRESA 		VARCHAR2(2) 	NOT NULL, 
  DTIMPSALDO 		DATE 			NOT NULL, 
  CDCONTCTBL 		VARCHAR2(20 ) 	NOT NULL, 
  VRIMPSALDO 		NUMBER 			NOT NULL, 
  IDSALDCOME 		VARCHAR2(1 ) 	NOT NULL, 
  CDSALDCOME 		VARCHAR2(21 ) 	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_IMPLANTSALDCOME CHECK (IDATIVO IN ('S','N')),
	CONSTRAINT CKC_IMPSALDCOME_IDSALDCOME CHECK (IDSALDCOME in ('B', 'F', 'C')), 
	CONSTRAINT PK_IMPLANTSALDCOME PRIMARY KEY (CDEMPRESA, IDSALDCOME, CDSALDCOME, CDCONTCTBL, DTIMPSALDO), 
	CONSTRAINT FKCTB00320CDCONTCTBL FOREIGN KEY (CDCONTCTBL) REFERENCES CONTCTBL (CDCONTCTBL), 
	CONSTRAINT FKCTB00321CDEMPRESA FOREIGN KEY (CDEMPRESA) REFERENCES EMPRESA (CDEMPRESA)
)
/

CREATE INDEX CTB00320_FK ON IMPLANTSALDCOME (CDCONTCTBL ASC)
/

CREATE INDEX CTB00321_FK ON IMPLANTSALDCOME (CDEMPRESA ASC)
/