Rollback Transaction

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Josef Gschwendtner
Posts: 6
Joined: Wed 04 Jul 2007 11:40

Rollback Transaction

Post by Josef Gschwendtner » Wed 01 Jul 2009 15:41

Hi,
we are in the process of testing IBDAC Suite (v. 3.00.0.4 for Delphi 7)
At the end of this message you can see the code of a short method which does not work as expected.

If I execute the method below and open the table Log afterwards in a new transaction (e.g. with IBExpert) I see an inserted record, which is weird because of the "Rollback" at the end of the method.

What is wrong here?

I hope somebody can enlighten me,
Josef


procedure TForm1.Button2Click(Sender: TObject);
begin
IBCQuery2.Transaction.StartTransaction;
with IBCQuery2 do begin
SQL.Clear;
SQL.Add('Insert into Log(Logpriority, Logcontext, Logmessage)');
SQL.Add(' values (:prio, :context, :message)');
ParamByName('prio').AsInteger := 2;
ParamByName('context').AsString := 'IBDAC';
ParamByName('message').AsString := 'Test 1';
ExecSQL;
end;
IBCQuery2.Transaction.Rollback;
end;

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 02 Jul 2009 08:54

You should set AutoCommit property of TIBCConnection or TIBCQuery to False.

When AutoCommit=True, CommitRetaining is performed after each execution.

Josef Gschwendtner
Posts: 6
Joined: Wed 04 Jul 2007 11:40

Post by Josef Gschwendtner » Thu 02 Jul 2009 13:25

Hi,

thank you for your quick response.
Yes, with AutoCommit = False the Rollback works, but I think this behavior conflicts with the explanation in IBDAC-help (see below).

Here the text from IBDAC-Help
Class
TCustomIBCDataSet

Syntax
property AutoCommit: boolean;

Remarks
When True and Connection.AutoCommit is True, and Connection.InTransaction is False, each update, insert or delete statement is automatically committed by database server.

-----

The current behavior gives us problems in converting an IBO application to IBDAC, because in IBO, I always could rollback an explicitly started transaction independently from the setting of Autocommit.

Regards,
Josef Gschwendtner

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 03 Jul 2009 09:23

Sorry, there is an mistake in the help. We'll fix it in the next IBDAC build.

IBDAC has such behaviour for compatibility with IBX.

You can try to use UniDAC instead of IBDAC. In UniDAC we have made the checking whether a transaction is started explicitly or implicitly, and disable AutoCommit automatically. In IBDAC you need to manually set AutoCommit of the connection component to False after you start a transaction.

Post Reply