Ver Mensaje Individual
  #3  
Antiguo 06-06-2023
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.734
Reputación: 20
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Creo que el orden de comprobaciones es incorrecto.
Primero miras si hay que hacer commit.
Si has hecho commit, el contador se voverá 0 y harás como si fuera la primera inserción.

En tu código, perparabas la sentencia y luego si se trataba de la MaxTenokatesInserteds hacías commit, con lo que ya no está preparada.

Código Delphi [-]
Procedure SaveTemplate;
Begin
  // Forzamos commit cada MaxTemplatesInserteds inserciones
  If TemplatesInserteds >= MaxTemplatesInserteds Then
  Begin
    // MaxTemplatesInserteds = Constante global = 10000
    TemplatesInserteds := 0;
    fTesting.IBQuery.Transaction.CommitRetaining;
  End;
  
  // Si es la primera insercion preparo sentencia SQL
  If TemplatesInserteds = 0 Then
  Begin
    // TemplatesInserteds = Variable global,inicialmente = 0
    // Preparamos Para inserción múltiple
    
    // Si la transaccion esta activa, revertimos
    If fTesting.IBTransaction.InTransaction Then
      fTesting.IBTransaction.Rollback;

    // Si la transaccion esta inactiva, la iniciamos
    If not fTesting.IBTransaction.InTransaction Then
      fTesting.IBTransaction.StartTransaction;
      
    fTesting.IBQuery.Close;
    fTesting.IBQuery.SQL.Text := 'EXECUTE PROCEDURE INSERT_NEW_CHART(: Breack, : ChartType, : xUp, : pUp, : xxUp, : ppUp, : xDown, : pDown, : xxDown, : ppDown)';
    fTesting.IBQuery.Prepare;
  End;
  
  If fTesting.IBQuery.Transaction.InTransaction Then
  Begin
    Inc(TemplatesInserteds);
    fTesting.IBQuery.Params.ParamByName('Breack').AsString := Template.Breack;
    fTesting.IBQuery.Params.ParamByName('ChartType').AsSmallInt := Template.ChartType;

    fTesting.IBQuery.Params.ParamByName('xUp').AsSmallInt := Template.xUp;
    fTesting.IBQuery.Params.ParamByName('pUp').AsSmallInt := Template.pUp;
    fTesting.IBQuery.Params.ParamByName('xxUp').AsSmallInt := Template.xxUp;
    fTesting.IBQuery.Params.ParamByName('ppUp').AsSmallInt := Template.ppUp;

    fTesting.IBQuery.Params.ParamByName('xDown').AsSmallInt := Template.xDown;
    fTesting.IBQuery.Params.ParamByName('pDown').AsSmallInt := Template.pDown;
    fTesting.IBQuery.Params.ParamByName('xxDown').AsSmallInt := Template.xxDown;
    fTesting.IBQuery.Params.ParamByName('ppDown').AsSmallInt := Template.ppDown;
    fTesting.IBQuery.ExecSQL;
  End;
End;
Responder Con Cita