Page 1 of 1

AssignConnect and AutoCommit

Posted: Thu 27 Oct 2011 07:47
by horsi
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.

Posted: Thu 27 Oct 2011 11:27
by AlexP
Hello,

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