Salesforce

How to find who is locking what table(s) using ABL

« Go Back

Information

 
TitleHow to find who is locking what table(s) using ABL
URL NameP27130
Article Number000137375
EnvironmentProduct: Progress
Version: 9.x
Product: OpenEdge
Version: 10.x, 11.x, 12.x
OS: All supported platforms
Question/Problem Description
How to find who is locking what table(s) using 4GL/ABL?

Sample 4GL/ABL code using the _Lock and _File database schema tables to find which user is locking records in which table

How to list the users, by name, who are locking table records  along with the names of the database tables involved?
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
The following ABL code uses _Lock and _File database schema tables to list all the users currently locking database table records along with the table names involved.  A copy of the procedure is attached to this Article ListUsersAndTheirLockedTables.p
  • A Temp-Table is explicitly used as the _Lock table is heavily used by the underlying database locking functionality
  • ​_Lock._Lock-Usr = ? means the VST lock "record" is currently not in use. Unused locks will all always be at the end of the table - there will not be a used "record" after the first one that reports unknowns. For further information refer to Article  Why does the _Lock table have records where _Lock-Usr = ?   
 
DEFINE TEMP-TABLE ttLock NO-UNDO
    FIELD iUSER AS INTEGER
    FIELD cName AS CHARACTER
    FIELD rRECID AS INTEGER
    FIELD iTABLE AS INTEGER
    FIELD cTABLE AS CHARACTER
    INDEX UserName cName ASCENDING.

FOR EACH _Lock WHERE
    _Lock._Lock-Usr <> ? AND
    _Lock._Lock-Recid <> ? NO-LOCK:

    /* Comment the next two statements to list the locked records individually */

FIND FIRST ttLock WHERE   ttLock.iUSER = _Lock._Lock-Usr AND ttLock.iTABLE = _Lock._Lock-Table NO-LOCK NO-ERROR.
    IF AVAILABLE ttLock THEN NEXT.
    CREATE ttLock.
    ASSIGN
        ttLock.iUSER = _Lock._Lock-Usr
        ttLock.cName = _Lock._Lock-Name
        ttLock.rRECID = _Lock._Lock-Recid
        ttLock.iTABLE = _Lock._Lock-Table.
END.

FOR EACH ttLock NO-LOCK:
    FIND FIRST _File WHERE _File._File-Number = iTABLE NO-LOCK NO-ERROR.
    ASSIGN
        cTABLE = _File._File-Name.
    DISPLAY
        ttLock.iUSER LABEL "User Number"
        ttLock.cName LABEL "User Name"
        ttLock.cTABLE LABEL "Table Name".
END.

 
Workaround
Notes
Keyword Phrase
Last Modified Date9/23/2021 9:05 PM

Powered by