Feedback
Did this article resolve your question/issue?

   

Article

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

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
Last Modified Date9/23/2021 9:05 PM
Attachment 
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.