Handle session failure

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
etam
Posts: 5
Joined: Wed 21 Nov 2007 11:28

Handle session failure

Post by etam » Wed 21 Nov 2007 11:58

In my program some statements are executed on OraSession AfterConnect.
The most important is to get a password protected role:

Code: Select all

set role my_role identified by "my_password";
also schema propery is used, so

Code: Select all

alter session set current_schema=my_schema;
also executed. (Connection user is my_user which is different from my_schema, and has no table in his own schema.)

When session unexpectedly disconnects (f.e. killed), the statements above should be rerun, before next query executed (or after first error).
It would be no problem, if query wouldn't automatically recreate the session (I don't know how), or it could be handled somehow, but I cannot find an even for it.

So I made this:

Code: Select all

procedure TMyDb.MyOrasessionError(Sender: TObject; E: EDAError; var Fail: Boolean);
// handling OnError event
begin
   if E is EOraError then begin
      if 28 = E.ErrorCode then begin   // ORA-00028: your sesson has been killed
         MySessionConnect; // Sets main session parameters
      end;
   end;
end;
The problem is that I can see in DBMonitor the statements to be executed, but next query get the "table not exists" error.
If I give direct table select grant (grant select on my_schema.my_table to my_user;),
then 'select * from my_schema.my_table;' works,
but 'select * from my_table;' doesn't.

It seems required statements ran, without consequences.

I use ODAC 5.70.0.28 with Delphi7, Oracle 9.2.0.4.0.

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

Post by Plash » Thu 22 Nov 2007 10:35

This problem is fixed in the last ODAC builds. AfterConnect event handler is called when session is reconnected after an error. You should update your ODAC to the last build of ODAC 5 or ODAC 6.

Post Reply