AssignConnect and AutoCommit

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
horsi
Posts: 14
Joined: Sat 15 Jan 2011 07:19

AssignConnect and AutoCommit

Post by horsi » Thu 27 Oct 2011 07:47

Hi to everyone!

Please look at the code:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  lConnection1: TUniConnection;
  lConnection2: TUniConnection;
  lSP2: TUniStoredProc;
begin
  lConnection1 := TUniConnection.Create(Self);
  Try
    lConnection1.LoginPrompt := False;
    lConnection1.ProviderName := OracleUniProvider1.GetProviderName;
    lConnection1.Username := 'USERNAME';
    lConnection1.Password := 'PASSWORD';
    lConnection1.Server := 'XEON';
    lConnection1.Connect;

    Assert(not lConnection1.InTransaction, 'lConnection1.InTransaction: should be False !');
    lConnection1.StartTransaction;

    Assert(lConnection1.InTransaction, 'lConnection1.InTransaction: should be True !');
    lConnection1.ExecSQL('INSERT INTO TEST_TABLE(SOMEVALUE) VALUES(1)', []);

    lConnection2 := TUniConnection.Create(Self);
    Try
      lConnection2.AssignConnect(lConnection1);
      Assert(lConnection2.InTransaction, 'lConnection2.InTransaction: should be True !');

      lConnection2.ExecSQL('BEGIN NULL; END;', []); //<-- !!! This does global commit !!!

      lSP2 := TUniStoredProc.Create(Self);
      lSP2.Connection := lConnection2;
      lSP2.SQL.Text := 'INSERT INTO TEST_TABLE(SOMEVALUE) VALUES(2)';
      lSP2.ExecSQL; //<-- !!! This does global commit, too !!!

    Finally
      lConnection2.Free
    End;

    lConnection1.Rollback
  Finally
    lConnection1.Free
  End
end;
How to solve above problem with auto-commits?

PS.
The same problem exists in the official version 4.0.2.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 27 Oct 2011 11:27

Hello,

Thank you for the information.
We have reproduced the problem.
We will try to fix it in the nearest product version.

Post Reply