Kbase 11187: Determine userid which has record locked using 4GL UNIX only
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
Determine userid which has record locked using 4GL UNIX only
PLEASE NOTE: This will not work with version 7 or later. See
Knowledge Base Entry 11200 Record Locking - Who Has The Record for
instructions for finding which user has a record locked.
INTRODUCTION:
=============
This Technical Support KnowledgeBase entry shows how
you can determine who has locked a record.
WHY YOU NEED TO KNOW THIS:
===========================
You may use this method to avoid the default message that PROGRESS
generates when you attempt to lock a record that is already locked by
another user.
PROCEDURAL APPROACH:
====================
Below are two PROGRESS procedures, chkuser.p and checker.p.
The checker.p procedure
is an example of how you would use chkuser.p to find out who has
locked a record.
/* chkuser.p - Get the userid of a user locking a record */
def input parameter m-recid as recid no-undo.
def input parameter m-db as char no-undo.
def output parameter m-userid as char no-undo.
if m-db = "" then m-db = dbname.
if opsys = "unix" then do:
/* we'll use PROMON here to find out who is locking the rec */
/* and store it in m-userid */
input through $DLC/promon
value(m-db)
value("<<EOF | grep " + string(m-recid) +
" | awk ~'~{ ~{ FS= "" "" ~} print $2 ~}~'" +
chr(10) + "4" +
chr(10) + "4" +
chr(10) + string(m-recid) +
chr(10) + "Q" +
chr(10) + "Q" +
chr(10) + "EOF") no-echo.
set m-userid.
input close.
end.
/* checker.p -- sample routine to check a lock */
/* To test this, start another PROGRESS session and */
/* lock the first customer record. Run this procedure */
/* in a second session and you'll see who is locking. */
def var v1-user as char no-undo.
repeat:
find first customer exclusive-lock no-error no-wait.
if locked(customer) then do:
find first customer no-lock no-error.
run chkuser.p (recid(customer), " ", output v1-user).
if v1-user = "" then next.
message "Customer Record is in use by " v1-user.
pause.
next.
end.
end.
Note: The chkuser.p procedure uses UNIX utilities and therefore
will work only on UNIX systems.
ON-LINE PROCEDURES OR UTILITIES:
===============================
PROGRESS promon utility
REFERENCES TO WRITTEN DOCUMENTATION:
====================================
PROGRESS System Administration II:General
PROGRESS Language Reference
Progress Software Technical Support Note # 11187