DisconnectedMode

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

DisconnectedMode

Post by MarkF » Tue 21 Apr 2009 18:57

Is there any other way to have a dataset retain its data after logout besides using DisconnectedMode set to true? Basically I don't want to turn disconnectedmode on in my application because it causes some state issues for me, but I'd like to be able to have my datasets keep their data.

Thanks for any help.

-Mark Ford
Benthic Software

In addition:
The documentation suggests that if Connect is explicitly called, then the connection will not be closed automatically (when using disconnectedmode set to true) however it appears that that is not the case (or I'm using it or understanding the use incorrectly.) If the connection didn't close in this case than it would solve my issues above. Any comments?

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

Post by Plash » Wed 22 Apr 2009 06:57

No, ODAC supports this feature only in the disconnected mode.

If Connect is explicitly called, the connection should not be closed. Please describe how to reproduce the problem when the connection closes.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Wed 22 Apr 2009 10:43

It looks like FConnectCount can fall to zero even if connect is explicitly called. I think it has something to do with autocommit set to false, and then calling session.commit in my code. It looks like it takes a few tries (in my program) before it decrements the counter enough to disconnect.

I wonder if it would be better to use a different boolean variable to designate that the user has explicitly called connect? It seems like FConnectCount could be accidentally decremented pretty easily. I see it gets set and reset quite a bit and is a bit hard to debug.

I'll try to make a simple example that causes the problem.

Thanks for the help.

-Mark

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Wed 22 Apr 2009 20:00

My guess above was correct. Calling either commit or rollback will cause the bug if Autocommit is false. Note that there's a comment in the code with a special check for FConnectCount < 0 that seems to be related to this.

Code: Select all

var
  OraSession: TOraSession;
  OraQuery: TOraQuery;
begin
  OraSession := TOraSession.Create(nil);
  OraSession.ConnectPrompt := False;
  OraSession.AutoCommit := False;
  OraSession.ThreadSafety := True;
  OraSession.Options.DisconnectedMode := True;

  OraQuery := TOraQuery.Create(nil);
  OraQuery.Session := OraSession;
  OraQuery.ReadOnly := True;
  OraQuery.AutoCommit := False;

  OraSession.Username := 'scott';
  OraSession.Password := 'tiger';
  OraSession.Server := 'mfms3';
  OraSession.Connect;

  OraQuery.SQL.Text := 'select * from emp';
  OraQuery.Execute;
  while not OraQuery.eof do
    OraQuery.Next;
  OraSession.Commit;

  if not OraSession.Connected then
    ShowMessage('Session disconnected due to FConnectCount issue.');

  OraQuery.Free;
  OraSession.Free;
end;
Let me know if you have any questions or comments!

-Mark

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

Post by Plash » Mon 27 Apr 2009 11:22

We have fixed this problem. The fix will be included in the next build of ODAC.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Tue 28 Apr 2009 02:12

Thanks!

-Mark

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Tue 26 May 2009 17:56

I have similar issue with SDAC. in disconnected mode the connection is closed, althouh I have the connect method explicitly called. affects the odac correction also the sdac bug? when it will be available?

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

Post by Plash » Wed 27 May 2009 07:12

This correction does not affect SDAC. Please describe the steps to reproduce the problem.

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Wed 27 May 2009 09:19

following steps: create a tmsconnection with disconnectedmode := true, call connect to make the connection active.
then execute following code:

Code: Select all

  msq := TMSQuery.Create(nil);
  try
    msq.Connection := msconnection1;
    msq.SQL.Text := 'select value from useroptions where usernr = :usernr and optionnr = :optionnr';
    msq.ParamByName('usernr').DataType := ftInteger;
    msq.ParamByName('usernr').Clear;
    msq.ParamByName('optionnr').AsInteger := 97;
//    msq.CommandTimeout := 0;
    msq.Open;
    msq.Close;
  finally
    msq.Free;
  end;
and the connection disconnects (you can see an audit logout in the profiler)

the useroptions is a simple table with the 3 named columns, all integer.

the logout happens only if the one parameter is NULL. if i include a value

Code: Select all

  msq := TMSQuery.Create(nil);
  try
    msq.Connection := msconnection1;
    msq.SQL.Text := 'select value from useroptions where usernr = :usernr and optionnr = :optionnr';
    msq.ParamByName('usernr').DataType := ftInteger;
    msq.ParamByName('usernr').AsInteger := 1;
    msq.ParamByName('optionnr').AsInteger := 97;
//    msq.CommandTimeout := 0;
    msq.Open;
    msq.Close;
  finally
    msq.Free;
  end;

the connection remains open...

:roll:

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Wed 27 May 2009 09:27

more info: the connection closes (audit logout in profiler), if the query returns 0 rows.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 27 May 2009 11:27

Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next SDAC build.

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Wed 27 May 2009 12:19

Thanks much. I just can't wait for the new build :)

Post Reply