declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate 'CREATE SEQUENCE COBRANCA_ADC_HIST_SEQ INCREMENT BY 1 START WITH 1 NOCYCLE';
  exception when object_exists then null;
end;
/
declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate 'CREATE TABLE COBRANCA_ADICIONAL_HISTORICO (
       COBRANCAADICIONALHISTORICO_ID NUMBER(15,0) NOT NULL,   
       COBRANCAADDPUNTOVENTA_ID  NUMBER(7) NOT NULL,
       CONTACORRENTEPTOVTA_ID    NUMBER(15,0),
       PUNTOVENTA_ID            NUMBER(7) NOT NULL,       
       VALOR_COBRANCA           NUMBER(7,2) NOT NULL,
       VALOR_ACUMULADO          NUMBER(7,2) NOT NULL,
       VALOR_APLICADO           NUMBER(7,2) NOT NULL,
       COBRANCA_EFETUADA        NUMBER(1) NOT NULL,
       FREQUENCIA_NA_DATA       VARCHAR2(30 BYTE),
	   DATA_REGISTRO            DATE NOT NULL,
       MOTIVO                   VARCHAR2(350 BYTE),    
       USUARIO_ID           NUMBER(7),
       PRIMARY KEY (COBRANCAADICIONALHISTORICO_ID),
       FOREIGN KEY (COBRANCAADDPUNTOVENTA_ID) REFERENCES COBRANCA_ADC_PUNTO_VENTA 
	)';
  exception when object_exists then null;
end;
