declare
    valor_atual number := 0;
begin
    begin
        execute immediate 'alter table control_efectivo modify (controlefectivo_id number(8,0))';
        
        exception when others then null;
    end;
    begin
        execute immediate 'drop sequence CONTROL_EFECTIVO_SEQ';
    
        execute immediate 'select coalesce(max(controlefectivo_id),0)+1 from CONTROL_EFECTIVO' INTO valor_atual;
    
        execute immediate 'CREATE SEQUENCE  CONTROL_EFECTIVO_SEQ  MINVALUE 0 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH ' || valor_atual  ||  ' CACHE 20 NOORDER  NOCYCLE' ;
    end;
end;
