Salesforce

How to retrieve user number and PID of DB connection

« Go Back

Information

 
TitleHow to retrieve user number and PID of DB connection
URL NameP19414
Article Number000135632
EnvironmentProduct: Progress
Version: 9.x
Product: OpenEdge
Version: All Supported Versions
OS: All Supported Platforms
Question/Problem Description
How to retrieve the user number for a connected database for the current session ?
How to find the PID of the Database server to which the current remote user is connected ?
How to retrieve the user PID of current session when connected to a database?
What is the purpose of the _Mycon-UserID field?
When was the MyConnection VST first introduced?
How to retrieve user number and PID of DB connection programmatically
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
The Virtual System Table _MyConnection introduced in Version 9.0A has one record for the current connection to a database, and provides the following fields:
  • _MyConn-NumSeqBuffers : Number of private read-only buffers currently allowed.
  • _MyConn-Pid : This user's process ID.
  • _MyConn-UsedSeqBuffers: Number of private read-only buffers currently in use.
  • _MyConn-UserId: The user's user ID.
When connected to a single database the following code will return the user number for the current 4GL/ABL session:
FIND _MyConnection.
 DISPLAY _MyConn-UserId.

To find the PID of the Database Server to which the current remote user is connected you first need to find the _myconnection record (there is only ever 1), then find the _connect record whose _connect-usr matches _myconnection._myconn-userid, then find the _connect record whose _connect-usr matches your _connect-server value.
 
/* When connected to multiple databases, this table should be queried with the DatabaseName: 
FIND <MyDatabase>._connect */

DEFINE VARIABLE iServerNum AS INTEGER NO-UNDO.

FIND _Myconnection.
FIND _connect WHERE _connect._connect-usr = _Myconnection._myconn-userid.

iServerNum = _connect._connect-server.
FIND FIRST _connect WHERE _connect._connect-usr = iServerNum.
DISPLAY _connect._connect-pid.

To show all database connections of the current client, listing the: logical DB name, physical DB name, and user number:
DEFINE VARIABLE iCount  AS INTEGER    NO-UNDO.
DEFINE VARIABLE hBuffer AS HANDLE     NO-UNDO.

DO iCount = 1 TO NUM-DBS:
    CREATE BUFFER hBuffer FOR TABLE LDBNAME(iCount) + "._myConnection".
    hBuffer:FIND-FIRST().    
    DISPLAY LDBNAME(iCount) PDBNAME(iCount) hBuffer::_myConn-UserID.
    DELETE OBJECT hBuffer.
END.

 
Workaround
Notes
References to Other Documentation:

Progress Documentation:
User connection (_MyConnection) (progress.com)

Progress Article(s):
How to disconnect all self and remote users from a database?
 
Keyword Phrase
Last Modified Date1/12/2021 6:14 PM

Powered by