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
If TemplatesInserteds >= MaxTemplatesInserteds Then
Begin
TemplatesInserteds := 0;
fTesting.IBQuery.Transaction.CommitRetaining;
End;
If TemplatesInserteds = 0 Then
Begin
If fTesting.IBTransaction.InTransaction Then
fTesting.IBTransaction.Rollback;
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;