Ver Mensaje Individual
  #39  
Antiguo 29-04-2023
ElDuc ElDuc is offline
Miembro
 
Registrado: jul 2004
Posts: 197
Reputación: 20
ElDuc Va por buen camino
Bueno Casimiro, estoy a punto de tirar la toalla.

He creado una tabla en una DB Firebird con la siguiente estructura.

Código SQL [-]
CREATE TABLE PRUEBAS (
  ID BIGINT DEFAULT 0 NOT NULL,
  MYINT INTEGER DEFAULT 0 NOT NULL,
  MYFLOAT FLOAT DEFAULT 0 NOT NULL,
  MYBOOL BOOLEAN DEFAULT 'FALSE' NOT NULL,
  MYSTRING CHAR(1) DEFAULT '!' NOT NULL);

Y he implementado un nuevo proyecto Delphi 2010, copiando, pegando y adaptando tu última recomendación.

Código Delphi [-]
Procedure TForm2.Button2Click(Sender:TObject);
Var
    IBDB:TIBDatabase;
    IBT:TIBTransaction;
    IBQ:TIBQuery;
    I, J:Integer;
Begin
Inherited;
IBDB := TIBDatabase.Create(Self);
IBT := TIBTransaction.Create(Self);
Try
    // Conexión a la base de datos
    IBDB.DatabaseName := 'D:\IKDB.GDB';
    IBDB.DefaultTransaction := IBT;
    IBT.DefaultDatabase := IBDB;

    // Aquí te pedirá nombre de usuario y contraseña
    IBDB.Connected := True;

    // Inicio transaccion
    IBT.StartTransaction;

    IBQ := TIBQuery.Create(Self);
    Try
        IBQ.DataBase := IBDB;
        IBQ.Transaction := IBT;

        // SQL para insertar los datos
        IBQ.SQL.Text := 'INSERT INTO Pruebas (Id, MyInt, MyFoat, MyBool, MyString) VALUES (:Id, :MyInt, :MyFloat, :MyBool, :MyString)';

        For I := 0 To 9 Do
            Begin
            For J := 1 To 10000 Do
                Begin
                IBQ.Params.ParamByName('Id').AsLargeInt := I * 10000 + J;
                IBQ.Params.ParamByName('MyInt').AsInteger := Random(1000);
                IBQ.Params.ParamByName('MyFloat').AsFloat := Random * 1000;
                IBQ.Params.ParamByName('MyBool').AsBoolean := Random(2) = 1;
                IBQ.Params.ParamByName('MyString').AsString := Char(Random(25) + 65);
                IBQ.ExecSQL;      <<<<<<<<< Aquí me este error:  'Attempt to get information about an unprepared dynamic SQL statement'
                End;

            // Hago commit de la transaccion cada 10000 registros.
            IBQ.Transaction.Commit;
            IBQ.Transaction.StartTransaction;
            End;

    Finally
        IBQ.Free;
    End;
    IBT.Free;
    IBDB.Free;
Except
    On E:Exception Do
        ShowMessage('ERROR ' + E.Message);
End;
End;

Cómo puedes ver en el código he añadido un indicador <<<<<<<<<<< dónde y qué error me da.

Si puedes mirarlo y decirme done lo hago mal, te lo agradeceré infinito.
Responder Con Cita