CheckConnection and TOracleEvent.InternalSession

topdogg

Member
I use a TOracleEvent component to receive dbms_pipe messages.

According to the docs, the TOracleEvent duplicates a connection to avoid interfering with the main session.

How can I make sure the duplicated connection is restored after the connection has been broken?

MySession.CheckConnection(true)

works for the main session, but if I attempt

MyEvent.InternalSession.CheckConnection(true)

I get an Access Violation in oran8.dll (and sometimes other dll's).

How should something like this be handled?

- t
 
You cannot check the session of the TOracleEvent component, because it is busy (waiting for events). You can only Stop the TOracleEvent and restart it.

------------------
Marco Kalter
Allround Automations
 
I solved the problem, although it only works if the "primary" connection goes down as well (but that's a workable solution in my case).

For those who may care, here is the code (slightly modified) which solved my problem:

if not CheckConnection(OracleSession1) then
begin
try
OracleEvent1.InternalSession.LogOff;
except
on E : EOracleError do
begin
Msg(OracleEvent1.InternalSession.Name + ': ' + E.Message, MSG_SEVERITY_HIGH);
end;
end;
try

Msg('Attempting to reconnect secondary connection...', MSG_SEVERITY_HIGH);
OracleEvent1.InternalSession.LogOn;

except
on E : EOracleError do
begin
Msg(OracleEvent1.InternalSession.Name + ': ' + E.Message, MSG_SEVERITY_HIGH);
end;
end;
end;

CheckConnection is simply a wrapper for TOracleSession.CheckConnection that returns false if the check returns anything other than ccOK.

And Msg is a custom error-logging routine.
 
Back
Top