UPDATE EVENTOREINF
   SET DSVERSAO = '2.01.02'
 WHERE DSVERSAO = '2.1.2'
/

COMMIT
/

CREATE TABLE LOTEREINF
(
    NRSEQLOTE		NUMBER      	        	 NOT NULL,
	CDEMPRESA       VARCHAR2(02)                 NOT NULL,
    DSVERSAO 		VARCHAR2(10) 		         NOT NULL,
    CDRESPOSTA      VARCHAR2(5)             	 NULL,
    DSRESPOSTA		VARCHAR2(4000)            	 NULL,
    DTHRRECEPCAO    DATE	                 	 NULL,
    NRPROTOCOLO     VARCHAR2(30)	           	 NULL,
    IDSTATUSLOTE    VARCHAR2(01)	DEFAULT 'N'  NOT NULL, 
    IDAMBIENTE      VARCHAR2(1)					 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_IDSTATUSLOTE_LOTEREINF CHECK  (IDSTATUSLOTE IN ('P','R','E','S','O','N')),
		CONSTRAINT CKC_IDAMBIENTE_LOTEREINF CHECK ( IDAMBIENTE IN ('1','2','3')),
		CONSTRAINT CKC_IDATIVO_LOTEREINF CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT PK_LOTEREINF PRIMARY KEY (NRSEQLOTE)
)
/

CREATE INDEX FIS00903_FK ON LOTEREINF(CDEMPRESA ASC)
/

ALTER TABLE LOTEREINF
   ADD CONSTRAINT FKFIS00903EMPRESA  FOREIGN KEY (CDEMPRESA)
      REFERENCES EMPRESA (CDEMPRESA)
/

ALTER TABLE LOTEREINF ADD IDTPENVIO VARCHAR2(20)
/

ALTER TABLE ENVIOEVENTOREINF ADD NRSEQLOTE  NUMBER NULL
/

CREATE INDEX FIS00904_FK ON ENVIOEVENTOREINF(NRSEQLOTE ASC)
/

ALTER TABLE ENVIOEVENTOREINF
   ADD CONSTRAINT FKFIS00904LOTEREINF  FOREIGN KEY (NRSEQLOTE)
      REFERENCES LOTEREINF (NRSEQLOTE)
/


ALTER TABLE PARAMMUNISERV ADD CDNATUREND VARCHAR2(20) NULL
/