hi,
when a TOraAlerter object is activated a new oracle session is created. In my multithreaded application i need to create many oracle sessions. Each thread have one session for insert/update/deletes and can have one ToraAlerter-Object. To have the possibility to know which session depends to which thread from the v$session database view, i set the client info via OraSession.ExecProc('DBMS_APPLICATION_INFO.SET_CLIENT_INFO',['Thread for ' + ThreadName]);
unfortunately i can't find a way to set the client info of the new spawned session of the TOraAlerter. Is there a way to set the Client-Info of the Extra-ToraAlerterSession?
If not, it would be great if CoreLab would implement an extra constructor for this class with a parameter ClientInfo for Setting the Client info of the new spawned session.
br, klaus.
Setting the Client Info for the TOraAlerter extra session
-
- Posts: 75
- Joined: Tue 04 Jan 2005 10:26
Re: Setting the Client Info for the TOraAlerter extra session
property Session does not help.
Access to FListenConnection via class helper is possible but calling FListenConnection.ExecCommand after start of FListenThread hangs application.
Need to set CLIENT_INFO for FListenConnection in "procedure TOCIAlerter.Start" (OraClasses.pas) after "FListenConnection.Connect('');".TOraAlerter Members
Session
Specifies the session for TOraAlerter to create an internal TOraSession object based on this session settings.
Access to FListenConnection via class helper is possible but calling FListenConnection.ExecCommand after start of FListenThread hangs application.
Re: Setting the Client Info for the TOraAlerter extra session
Hello,
We couldn't reproduce the issue. Check this behavior on the latest ODAC version 9.6.21 and let us know the result.
We couldn't reproduce the issue. Check this behavior on the latest ODAC version 9.6.21 and let us know the result.
-
- Posts: 75
- Joined: Tue 04 Jan 2005 10:26
Re: Setting the Client Info for the TOraAlerter extra session
Code: Select all
program AlerterTest;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils, Ora, OraAlerter;
var
S: TOraSession;
A: TOraAlerter;
Q: TOraQuery;
begin
S := TOraSession.Create(nil);
S.ConnectString := 'system/manager@orcl';
S.Connect;
S.ExecSQL('BEGIN DBMS_APPLICATION_INFO.SET_CLIENT_INFO(''Main-Session''); END;');
A := TOraAlerter.Create(nil);
A.Session := S;
A.EventType := etAlert;
A.Events := 'dummy';
A.Interval := 5;
A.TimeOut := -1;
A.Active := True;
Q := TOraQuery.Create(nil);
Q.SQL.Text := 'SELECT SID,LOGON_TIME,PROGRAM,CLIENT_INFO' +
'FROM V$SESSION WHERE UPPER(PROGRAM) = UPPER(:P)';
Q.ParamByName('P').AsString := ExtractFileName(ParamStr(0));
Q.Open;
Writeln('SID':4,'LOGON_TIME':20,'PROGRAM':20,' CLIENT_INFO');
while not Q.EOF do
begin
Writeln(Q.Fields[0].AsString:4, Q.Fields[1].AsString:20,
Q.Fields[2].AsString:20, ' ', Q.Fields[3].AsString);
Q.Next;
end;
Readln;
end.
SID LOGON_TIME PROGRAM CLIENT_INFO
189 18.01.2016 11:53:13 AlerterTest.exe
269 18.01.2016 11:53:13 AlerterTest.exe Main-Session
Re: Setting the Client Info for the TOraAlerter extra session
If you have ODAC with source code, you can add a call of SET_CLIENT_INFO directly in the TOCIAlerter.Start method code. There is no other way to get access to internal connection.