ALTER TABLE PARAVEND ADD IDUTILINTVALPRE VARCHAR2(1) NULL
   CONSTRAINT CKC_IDUTILINTVALPRE_PARAVEND CHECK (IDUTILINTVALPRE IN ('S','N'))
/

ALTER TABLE PARAVEND ADD CDURLINTVALPRE VARCHAR2(250) NULL
/

ALTER TABLE PARAVEND ADD NRSEGREQVALPRE VARCHAR2(2) NULL
/

ALTER TABLE TIPORECE DROP CONSTRAINT CKC_IDTIPORECE 
/ 
 
ALTER TABLE TIPORECE ADD CONSTRAINT CKC_IDTIPORECE CHECK (IDTIPORECE IN ('1','2','3','4','5','6','7','8','9','A','B','C','E','F','G','H','I','J','W','K')) 
/

ALTER TABLE VENDA ADD IDREQVALPRE VARCHAR2(36) NULL
/

CREATE TABLE VALEPRESENTE (
   CDFILIAL       VARCHAR2(4)  NOT NULL,
   CDCAIXA        VARCHAR2(3)  NOT NULL,
   NRSEQVENDA     VARCHAR2(10) NOT NULL,
   NRSEQVALPRE    VARCHAR2(3)  NOT NULL,
   CDCARTVALPRE   VARCHAR2(20) NOT NULL,
   NRORG          NUMBER       DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO        VARCHAR2(1)  DEFAULT 'S' NOT NULL
		CONSTRAINT CKC_IDATIVO_VALEPRESENTE CHECK (IDATIVO IN ('S','N')),
   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' NULL,
		CONSTRAINT PK_VALEPRESENTE PRIMARY KEY (CDFILIAL, CDCAIXA, NRSEQVENDA, NRSEQVALPRE)
)
/

CREATE INDEX VND00873_FK ON VALEPRESENTE (CDFILIAL ASC, CDCAIXA ASC, NRSEQVENDA ASC)
/

ALTER TABLE VALEPRESENTE
   ADD CONSTRAINT FKVND00873VENDA FOREIGN KEY (CDFILIAL, CDCAIXA, NRSEQVENDA)
      REFERENCES VENDA (CDFILIAL, CDCAIXA, NRSEQVENDA)
/
