Feedback
Did this article resolve your question/issue?

   

Article

How to check how long a user has held a lock

Information

 
TitleHow to check how long a user has held a lock
URL NameHow-to-check-how-long-a-user-has-held-a-lock
Article Number000184068
EnvironmentProduct: OpenEdge
Version: 10.x, 11.x, 12.x
OS: All supported platforms
Question/Problem Description
How to find how long a user has been holding a record lock?
How to monitor record lock duration with VST's?

 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
The following code example will display how long a user with an open transaction has been holding a record lock:
 
DEFINE TEMP-TABLE lockduration NO-UNDO
    FIELD usrnum AS INT 
    FIELD transid AS INT64 
    FIELD lock-recid AS INT64 
    FIELD tablenum AS INT
    FIELD lockduration AS DATETIME
    FIELD timediff AS DECIMAL FORMAT ">>>>>>>>>>9"
    INDEX iLockDur AS PRIMARY usrnum lock-recid tablenum .

PAUSE 0 BEFORE-HIDE.

REPEAT:
    FOR EACH _lock.
        FIND FIRST lockduration WHERE _lock-usr = lockduration.usrnum 
        AND _lock-recid = lockduration.lock-recid
        AND _lock-table = lockduration.tablenum NO-ERROR.
        
    IF AVAILABLE (lockduration) THEN
    timediff = NOW - lockduration.
    ELSE
    DO:
        CREATE lockduration.
        ASSIGN 
        lockduration.usrnum = _lock._lock-usr
        lockduration.transid = _lock._lock-transid
        lockduration.lock-recid = _lock._lock-recid
        lockduration.tablenum = _lock._lock-table
        lockduration.lockduration = NOW.
        END.
    END. 
    FOR EACH lockduration.
    FIND FIRST  _lock WHERE _lock-recid = lockduration.lock-recid
    AND _lock-usr = lockduration.usrnum
    AND _lock-transid = lockduration.transid
    AND _lock-table = lockduration.tablenum NO-ERROR.
    IF NOT AVAILABLE _lock THEN
    DELETE lockduration.
END.


PAUSE 20 BEFORE-HIDE.
PAUSE 4 BEFORE-HIDE.
FOR EACH lockduration.
    DISP lockduration.
END.
END.

 
Workaround
Notes
Last Modified Date3/3/2021 9:01 PM
Attachment 
Files 1. 00346285.p
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.