ALTER TABLE CONTOPECTBL ADD DTINIINTCONTVEXT DATE NULL
/

ALTER TABLE CONTOPECTBL ADD DTFININTCONTVEXT  DATE NULL
/

ALTER TABLE VENDA ADD IDAPROVEXTEMP VARCHAR2(01) DEFAULT 'N' NOT NULL
    CONSTRAINT CKC_IDAPROVEXTEMP_VENDA CHECK (IDAPROVEXTEMP  IN ('N','S'))
/

ALTER TABLE VENDA ADD DTREFPERIODO DATE NULL
/
 
DECLARE 
V_SEQUENCIAL VARCHAR2(20);
BEGIN 
   FOR C_EMP IN (select distinct cdempresa
 from lanclote
 where cdlote = '12') LOOP
 
     SELECT NVL(MAX(NRLANCLOTE ),0)    
     into V_SEQUENCIAL
           FROM LANCLOTE
          WHERE CDEMPRESA = C_EMP.CDEMPRESA
            AND CDLOTE = '12';
          
          insert into novocodigo
          (cdCONTADOR, NRSEQUENCIAL)
          values
          ('LANCLOTE'||C_EMP.CDEMPRESA||'12', LPAD(V_SEQUENCIAL,20,'0'));
            
END LOOP;
END;
/

ALTER TABLE MOVCAIXA ADD IDAPROVEXTEMP VARCHAR2(01) DEFAULT 'N' NOT NULL
    CONSTRAINT CKC_IDAPROVEXTEMP_MOVCAIXA CHECK (IDAPROVEXTEMP  IN ('N','S'))
/

ALTER TABLE RELACNFCEAPROV ADD IDSITUVENDA VARCHAR2(01) DEFAULT 'O' NOT NULL
/

ALTER TABLE RELACNFCEAPROV ADD IDAPROVACAONFCE VARCHAR2(01) DEFAULT 'A' NOT NULL
/   