Setting the Client Info for the TOraAlerter extra session

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
keckhard
Posts: 12
Joined: Fri 08 Apr 2005 09:18

Setting the Client Info for the TOraAlerter extra session

Post by keckhard » Mon 11 Apr 2005 12:52

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.

Alex
Posts: 655
Joined: Mon 08 Nov 2004 08:39

Post by Alex » Mon 11 Apr 2005 15:11

We will publish internal TOraAlerter session object in the next ODAC build.

cis-wurzen
Posts: 75
Joined: Tue 04 Jan 2005 10:26

Re: Setting the Client Info for the TOraAlerter extra session

Post by cis-wurzen » Wed 13 Jan 2016 15:26

property Session does not help.
TOraAlerter Members

Session
Specifies the session for TOraAlerter to create an internal TOraSession object based on this session settings.
Need to set CLIENT_INFO for FListenConnection in "procedure TOCIAlerter.Start" (OraClasses.pas) after "FListenConnection.Connect('');".

Access to FListenConnection via class helper is possible but calling FListenConnection.ExecCommand after start of FListenThread hangs application.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Setting the Client Info for the TOraAlerter extra session

Post by AlexP » Thu 14 Jan 2016 10:26

Hello,

We couldn't reproduce the issue. Check this behavior on the latest ODAC version 9.6.21 and let us know the result.

cis-wurzen
Posts: 75
Joined: Tue 04 Jan 2005 10:26

Re: Setting the Client Info for the TOraAlerter extra session

Post by cis-wurzen » Mon 18 Jan 2016 10:56

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.
Output
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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Setting the Client Info for the TOraAlerter extra session

Post by AlexP » Wed 20 Jan 2016 09:46

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.

Post Reply