Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Current Server active/connected sessions?
Mon, Mar 25 2019 7:27 PMPermanent Link

Ian Branch

Avatar

Hi Team,
In C/S Mode, I want to be able to get the count of the current active/connected Server sessions there are at any point in time.

I tried using TEDBEngine.SessionCount but that only seems to give me the count for the App rather than total sessions.
I also tried TEDBEngine.GetServerConnectedSessionCount but that always gives me 0.

Is there something I have missed in trying to use these functions?

I am thinking I have to do a SQL extract/count of Server Sessions but hoping there is an easier way.

Regards & TIA,
Ian
Mon, Mar 25 2019 7:28 PMPermanent Link

Ian Branch

Avatar

Should have said.  D10.3.1, EDB 2.31b1.
Tue, Mar 26 2019 1:07 AMPermanent Link

Steve Gill

Avatar

Hi Ian,

<< In C/S Mode, I want to be able to get the count of the current active/connected Server sessions there are at any point in time.

I tried using TEDBEngine.SessionCount but that only seems to give me the count for the App rather than total sessions.
I also tried TEDBEngine.GetServerConnectedSessionCount but that always gives me 0.

Is there something I have missed in trying to use these functions?

I am thinking I have to do a SQL extract/count of Server Sessions but hoping there is an easier way. >>

I tend to do most things using stored procedures and functions. I'm not sure if this helps but I use this function to display session counts:

CREATE FUNCTION "GetSessionCount" ()
RETURNS INTEGER
BEGIN    

  DECLARE TempCursor SENSITIVE CURSOR FOR SQLStatement;
  DECLARE SessionCount INTEGER;

  PREPARE SQLStatement FROM
     'SELECT COUNT(*) AS SessionCount
        FROM Configuration.ServerSessions
       WHERE User <> ''Administrator''
         AND Connected = True';

  OPEN TempCursor;

  IF (ROWCOUNT(TempCursor) > 0) THEN
     FETCH FIRST FROM TempCursor('SessionCount') INTO SessionCount;
  ELSE
     SET SessionCount = 0;
  END IF;

  CLOSE TempCursor;

  RETURN SessionCount;
END


= Steve
Tue, Mar 26 2019 2:18 AMPermanent Link

Ian Branch

Avatar

Hi Steve,
That can work.  I haven't created/used server based functions before.  How is this then called from Delphi?

Regards,
Ian
Thu, Mar 28 2019 6:16 PMPermanent Link

Steve Gill

Avatar

Hi Ian,

<< That can work.  I haven't created/used server based functions before.  How is this then called from Delphi? >>

Just drop a TEDBStoredProc component on the datamodule or form and set the StoredProcName to the function name (see attached image).

Then call it using code like this:

  spGetSessionCount.Prepare;
  spGetSessionCount.ExecProc;
  SessionCount := spGetSessionCount.ParamByName('Result').AsInteger;
  spGetSessionCount.UnPrepare;

= Steve



Attachments: GetSessionCount.png
Sun, Mar 31 2019 7:23 PMPermanent Link

Ian Branch

Avatar

Thanks Steve,
Chalk up another first.
First time I have used a Stored Procedure.  Procedure & Component.
Thanks for the education.

Regards,
Ian
Mon, Apr 1 2019 2:53 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ian,

<< I also tried TEDBEngine.GetServerConnectedSessionCount but that always gives me 0. >>

That property only works if the TEDBEngine instance is acting as a server and you're accessing the property from the server process itself.

Tim Young
Elevate Software
www.elevatesoft.com
Image