Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Bases de datos > Firebird e Interbase
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #14  
Antiguo 28-03-2013
Avatar de cesarsoftware
cesarsoftware cesarsoftware is offline
Miembro
 
Registrado: nov 2006
Posts: 241
Poder: 20
cesarsoftware Va por buen camino
Cita:
Empezado por Casimiro Notevi Ver Mensaje
Un fallo de su (cesarsoftware) software
Je,je,je, muy gracioso

El cliente me llamo ayer informado que "mi software" informaba de que no podia leer el identificador (el soft continua, quizas no debiera, porque lee el resultado de un ensayo de amortiguadores y luego indica a los distintos robots lo que tiene que hacer en funcion al resultado del ensayo) y que al leer la bbdd con un software de terceros solo decia (segun el cliente) "table corrupted" o algo asi, me lo dijo por telefono, pero que otras tablas si podia leer.
Como me dijo que tiraria de copia, la verdad es que no se me ocurrio pedirle que me leyera el firebirl.log.

Uso la version 2.5.1 de 64 bits.

La funcion para leer el identificador es la siguiente
Código Delphi [-]
function TFormMain.LeeIdentificadorBBDD(): integer;
var
  identificador: integer;
  DataSet: TSQLDataset;
  msg: string;
begin
  Result := -1;
  if conectadoBase = False then
    Exit;
  try
    FormBBDD.SQLConnection.Execute('SELECT MAX(IDENTIFICADOR) FROM ENSAYOS', nil, @DataSet);
    identificador := Dataset.Fields[0].AsInteger;
    FreeAndNil(DataSet);
    Inc(identificador);
    Result := identificador;
  except
    FreeAndNil(DataSet);
    Exit;
  end;
  msg := 'Identificador de ensayo ' + IntToStrMil(identificador);
  ListBoxMonitor.ItemIndex := ListBoxMonitor.Items.Add(msg);
  FreeAndNil(DataSet);
end;

La funcion para grabar datos (unos 3000 por ensayo (1 ensayo cada 24 segundos)) en la siguiente (se graban 2 tablas y solo ha fallado la tabla LECTURAS.
Código Delphi [-]
function TFormMain.GuardaEnsayoBBDD(identificador, resultado: integer): boolean;
var
  i: longword;
  tag: longword;
  Transaccion: TDBXTransaction;
  sFecha, msg, sql: string;
  tIni, tFin, tSegIni, tSegFin, tiempo: int64;
  r: boolean;
begin
  Result := False;
  if conectadoBase = False then
    Exit;
  if identificador = -1 then
  begin
    ListBoxMonitor.ItemIndex := ListBoxMonitor.Items.Add(
     'Nº de identificador erroneo ' + IntToStr(BBDDidentificador));
    Exit;
  end;
  if RxLecturas = 0 then
  begin
    ListBoxMonitor.ItemIndex := ListBoxMonitor.Items.Add(
     'No hay lecturas que grabar');
    Exit;
  end;
  // Grabar los datos
  r := True;
  tag := ListBoxMonitor.Items.Count + 1;
  tIni := GetTickCount();
  msg := 'Comenzando transacción';
  ListBoxMonitor.ItemIndex := ListBoxMonitor.Items.Add(msg);
  Transaccion := FormBBDD.SQLConnection.BeginTransaction;
  if Transaccion = nil then
  begin
    ListBoxMonitor.ItemIndex := ListBoxMonitor.Items.Add(
     'No se creo la trasacción');
    Exit;
  end;
  tSegIni := GetTickCount();
  // Grabar el ensayo
  sql := DateToStr(Now());
  sFecha := Copy(sql, 7, 4) + '/' +
            Copy(sql, 4, 2) + '/' +
            Copy(sql, 1, 2);
  sql := 'INSERT INTO ENSAYOS (';
  sql := sql + 'LINEA,IDENTIFICADOR,FECHA,HORA,ORDEN,MODELO,RESULTADO,';
  sql := sql + 'V1_MAX_EXT,V1_MAX_COM,V2_MAX_EXT,V2_MAX_COM,';
  sql := sql + 'V3_MAX_EXT,V3_MAX_COM,V4_MAX_EXT,V4_MAX_COM,';
  sql := sql + 'V5_MAX_EXT,V5_MAX_COM,V1_AREA_0,V1_AREA_1,V1_AREA_2,';
  sql := sql + 'V1_AREA_3,V2_AREA_0,V2_AREA_1,V2_AREA_2,V2_AREA_3,V3_AREA_0,';
  sql := sql + 'V3_AREA_1,V3_AREA_2,V3_AREA_3,V4_AREA_0,V4_AREA_1,V4_AREA_2,';
  sql := sql + 'V4_AREA_3,V5_AREA_0,V5_AREA_1,V5_AREA_2,V5_AREA_3';
  sql := sql + ') VALUES (';
  sql := sql + IntToStr(NombreLinea) + ',';
  sql := sql + IntToStr(identificador) + ',''';
  sql := sql + sFecha + ''',''';
  sql := sql + TimeToStr(Now()) + ''',''';
  sql := sql + Trim(EditOF.Text) + ''',''';
  sql := sql + Trim(EditModelo.Text) + ''',';
  sql := sql + IntToStr(resultado) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(VmaxExt[0])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(VmaxCom[0])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(VmaxExt[1])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(VmaxCom[1])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(VmaxExt[2])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(VmaxCom[2])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(VmaxExt[3])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(VmaxCom[3])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(VmaxExt[4])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(VmaxCom[4])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[0, 0])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[0, 1])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[0, 2])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[0, 3])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[1, 0])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[1, 1])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[1, 2])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[1, 3])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[2, 0])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[2, 1])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[2, 2])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[2, 3])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[3, 0])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[3, 1])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[3, 2])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[3, 3])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[4, 0])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[4, 1])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[4, 2])) + ',';
  sql := sql + FloatStrComaToPunto(FloatToStr(EnsayoGrafica.areaTotal[4, 3]));
  sql := sql + ')';
  try
    FormBBDD.SQLConnection.ExecuteDirect(sql);
  except
    on E: Exception do
    begin
      ListBoxMonitor.ItemIndex := ListBoxMonitor.Items.Add(
       'No se ha guardado el ensayo');
      Result := False;
      FormBBDD.SQLConnection.RollbackFreeAndNil(Transaccion);
      Exit;
    end;
  end;
  // Grabar los datos
  for i := 0 to RxLecturas - 1 do
  begin
    sql := 'INSERT INTO LECTURAS (';
    sql := sql + 'LINEA,IDENTIFICADOR,V,CICLO,LECTURA,POSICION,ESFUERZO,VELOCIDAD)';
    sql := sql + ' VALUES (';
    sql := sql + IntToStr(NombreLinea) + ',';
    sql := sql + IntToStr(identificador) + ',';
    sql := sql + IntToStr(aSpeed[i]) + ',';
    sql := sql + IntToStr(aCiclo[i]) + ',';
    sql := sql + IntToStr(i + 1) + ',';
    sql := sql + IntToStr(aPosicion[i]) + ',';
    sql := sql + IntToStr(aFuerza[i]) + ',';
    sql := sql + IntToStr(aVelocidad[i]);
    sql := sql + ')';
    try
      FormBBDD.SQLConnection.ExecuteDirect(sql);
    except
      on E: Exception do
      begin
        ListBoxMonitor.ItemIndex := ListBoxMonitor.Items.Add(
         'No se ha guardado la lectura nº ' + IntToStr(i));
        r := False;
        Break;
      end;
    end;
    tSegFin := GetTickCount();
    if (tSegFin - tSegIni) >= 1000 then
    begin
      tSegIni := GetTickCount();
      msg := 'Grabados ' + IntToStrMil(i) + ' de ' + IntToStrMil(RxLecturas - 1);
      ListBoxMonitor.Items[tag - 1] := msg;
      Application.ProcessMessages;
    end;
  end;
  msg := 'Grabados ' + IntToStrMil(i) + ' de ' + IntToStrMil(RxLecturas - 1);
  ListBoxMonitor.Items[tag - 1] := msg;
  if r = True then
  begin
    try
      FormBBDD.SQLConnection.CommitFreeAndNil(Transaccion);
    except
      on E: Exception do
      begin
        ListBoxMonitor.ItemIndex := ListBoxMonitor.Items.Add(
         'No se ha guardado la trasacción');
        FormBBDD.SQLConnection.RollbackFreeAndNil(Transaccion);
        Exit;
      end;
    end;
  end
  else
  begin
    ListBoxMonitor.ItemIndex := ListBoxMonitor.Items.Add(
     'Se han registrado errores');
    FormBBDD.SQLConnection.RollbackFreeAndNil(Transaccion);
    Exit;
  end;
  tFin := GetTickCount();
  tiempo := (tFin - tIni);
  msg:= DateTimeToStr(Now()) + ' - ' + IntToStrMil(RxLecturas - 1) +
        Format(' - %.2f', [tiempo / 1000]) + ' Seg.';
    ListBoxMonitor.Items[tag - 1] := msg;
  Result := True;
end;

Quizas no hago bien las cosas, ¿como veis las funciones? ¿Os parecen que pueden corronper? Hasta la fecha a registrado correctamente mas de 100.000 ensayos (unos 17 gigabytes)

Saludos.
__________________
Disfruta de la vida ahora, vas a estar muerto mucho tiempo.

Última edición por cesarsoftware fecha: 28-03-2013 a las 20:48:52.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Hay tantos casos de corrupción que... Casimiro Noteví La Taberna 24 04-03-2013 13:27:25
Una mas de demencia o de corrupción política escafandra La Taberna 16 28-12-2012 09:59:49
Detectar corrupción de memoria ALAM C++ Builder 1 27-07-2007 12:09:19
Corrupción en la base de datos. AMINOA2R Firebird e Interbase 2 03-06-2005 09:54:58
Corrupción de Tablas TDworD Tablas planas 6 29-09-2004 17:29:38


La franja horaria es GMT +2. Ahora son las 19:00:10.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi