Kbase 11200: Recording Locking - Who has the record ?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  9/15/1999 |
|
Recording Locking - Who has the record ?
As everyone who has worked in a multi-user environment knows, when you
attempt to take a lock on a record which already has a lock, PROGRESS
informs you of who has the pre-existing lock by means of a status
message at the bottom of the screen. However, you have only two
choices
as to what to do next: either wait for the record to become available,
or to press STOP, which returns you to your startup procedure. This
restriction is often undesirable, since any data entered in a screen
up to that point is lost.
The way around the PROGRESS-imposed wait function is to test for a
lock using the LOCKED function, and then give the user a choice of
things to do. However, PROGRESS does not have a function which
identifies the name, office location, email address and phone number
of who is locking a particular record. If you had this information, it
would be so much easier to let them know that they were keeping you
from getting your work done!
Because input through was changed to create a shell of its own in
version 7, there are two different ways to find who has the record
locked.
VERSION 6 AND EARLIER
The following procedure, which works only for UNIX, will return the
userid locking a particular record. If you want their address and
phone number, you'll have to program it yourself!
The procedure needs three parameters passed to it. The first is the
RECID of the record that is locked. The easiest way to get this is to
read the record with no-lock and use the RECID function.
The second parameter is the physical name of the database which
contains the record. If you are using Version 5 of PROGRESS or are
connected to only one database, pass the null string "".
The third parameter (an input-output parameter) is the variable which
will contain the userid of the person who is locking the record.
(EDITOR'S NOTE: These routines have not yet been checked for
functionality nor typos)
/* chkuser.p Get the useridd 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:
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 */
def var v1-user as char no-undo.
repeat:
find customer where cust-num = 10 exclusive-lock no-error no-wait.
if locked(customer) then do:
find customer where cust-num = 10 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.
The procedure works by shelling out to UNIX and invoking the PROGRESS
database monitor 'promon'. It passes characters to promon which
simulate pressing the appropriate keys to access the menu option which
will show the userid and record id of a locked record. (e.g. pressing
4 <enter>, 4 <enter>, recid <enter>, q <enter>, and q <enter>,
The 'grep' statement allows only the line with the correct recid to be
displayed. The 'awk' command extracts the second field from the line,
which is the userid of the person locking the record. This is piped
through and INPUT THROUGH statement, which SETs the m-userid parameter
.
The INPUT is then closed.
VERSION 7 AND LATER
The following code samples have been tested on our systems but may
need to be adjusted for your particular type of UNIX.
The following code samples assume that the first customer record has
been locked. Checker.p can be changed to reflect the record you are
looking for and your database.
/* checker.p */
DEFINE VARIABLE v1-user AS CHARACTER NO-UNDO.
DEFINE VAR m-db AS CHARACTER FORMAT "x(15)".
DEFINE VAR m-recid AS RECID.
m-db = "sports".
FIND FIRST customer NO-LOCK NO-ERROR.
m-recid = RECID(customer).
IF OPSYS = "unix" THEN DO:
unix silent whosgot value(m-db) value(m-recid).
END.
INPUT FROM holder.
SET v1-user.
INPUT CLOSE.
/* whosgot */
# dbname=$1
# recid=$2
echo "4" > who.has
echo "4" >> who.has
echo $2 >> who.has
echo "Q" >> who.has
echo "Q" >> who.has
$DLC/bin/promon $1 < who.has 2>/dev
ull | grep $2 | awk '{ {FS= " " }
print $2 }' >holder
print $2~ }' >holder
VERSION 8.2 AND LATER
In Proress 8.2 and later the Virtual System Tables (VST) can be used
for this purpose.
Please refer to kbase 19136 Record Locking - How to know who has the
record using VST for more information on this.
Progress Software Technical Support Note # 11200