Handle session failure
Posted: 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:
also schema propery is used, so
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:
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.
The most important is to get a password protected role:
Code: Select all
set role my_role identified by "my_password";Code: Select all
alter session set current_schema=my_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;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.