CREATE TABLE PACOTEINTEGRACAO
  (
   CDSERVPAC         		VARCHAR2(10)       		NOT NULL,   
   CDFILIAL         	 	VARCHAR2(4)  	  	NULL,
   IDSTATUS       		VARCHAR2(1)         		DEFAULT 'S' NULL,
	CONSTRAINT CKC_IDSTATUS_PACOTEINTEGRACAO CHECK (IDSTATUS IN ('S','E', 'A')),         
   DSSERIALHD         	VARCHAR2(1000)        	NULL,   
   DSMACADDRESS       	VARCHAR2(1000) 	  	NOT NULL, 
   DTSERVIDORPAC           	DATE                		DEFAULT SYSDATE,
   SGREDE        		VARCHAR2(5) 	  	NOT NULL,          
   NRORG                       	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     		DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_PACOTEINT 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',
      CONSTRAINT PK_PACOTEINTEGRACAO PRIMARY KEY (CDSERVPAC)
)
/
CREATE INDEX VND00751_FK ON PACOTEINTEGRACAO (CDFILIAL ASC)
/
ALTER TABLE PACOTEINTEGRACAO 
	ADD CONSTRAINT FKVND00751FILIAL FOREIGN KEY (CDFILIAL) 
		REFERENCES FILIAL(CDFILIAL)
/
ALTER TABLE LOGINTEGRACAO ADD CDSERVPAC VARCHAR2(10) NULL
/
ALTER TABLE VENDA DROP CONSTRAINT CKC_VENDA_IDVENDEXPORT
/
ALTER TABLE VENDA ADD CONSTRAINT CKC_VENDA_IDVENDEXPORT CHECK (IDVENDEXPORT IN ('S', 'N', 'E'))