Kbase P27146: How to find who is locking what table(s) using 4GL under 8.2
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  6/16/2003 |
|
Status: Unverified
GOAL:
How to find who is locking what table(s) using 4GL under 8.2x & 8.3x?
FACT(s) (Environment):
Progress 8.2x
FACT(s) (Environment):
Progress 8.3x
FIX:
/******************************** Step 1: ***********************************/
/* The following code will generate a 4GL procedure named dbTableRecid.p. The */
/* generated procedure will popualte a temp table of all database records and */
/* table names that will be used to get the tables names of locked records. */
/******************************************************************************/
OUTPUT TO dbTableRecid.p.
PUT "DEFINE TEMP-TABLE ttRecidTable" FORMAT "X(80)" SKIP.
PUT " FIELD cTableName AS CHARACTER" FORMAT "X(80)" SKIP.
PUT " FIELD rRecordid AS RECID" FORMAT "X(80)" SKIP.
PUT " INDEX RecordId IS PRIMARY rRecordid ASCENDING." FORMAT "X(80)" SKIP(1).
PUT "DEFINE INPUT PARAMETER ipcRecordNumber AS INTEGER NO-UNDO." FORMAT "X(80)" SKIP.
PUT "DEFINE OUTPUT PARAMETER opcTableName AS CHARACTER NO-UNDO." FORMAT "X(80)" SKIP(1).
FOR EACH _File WHERE _File-Number > 0 AND _File-Number < 32767 NO-LOCK:
PUT "FOR EACH " + _File-Name + " NO-LOCK:" FORMAT "X(80)" SKIP.
PUT " CREATE ttRecidTable." FORMAT "X(132)" SKIP.
PUT " ASSIGN" FORMAT "X(80)" SKIP.
PUT " cTableName = " + '"' + _File-Name + '"' FORMAT "X(80)" SKIP.
PUT " rRecordid = RECID(" + _File-Name + ")." FORMAT "X(80)" SKIP.
PUT "END." SKIP(1).
END.
PUT " FIND FIRST ttRecidTable WHERE" FORMAT "X(80)" SKIP.
PUT " ttRecidTable.rRecordid = ipcRecordNumber" FORMAT "X(80)" SKIP.
PUT " NO-LOCK NO-ERROR." FORMAT "X(80)" SKIP.
PUT " ASSIGN" FORMAT "X(80)" SKIP.
PUT " opcTableName = ttRecidTable.cTableName." FORMAT "X(80)" SKIP(1).
PUT "RETURN.".
OUTPUT CLOSE.
/******************************************************************************/
/*Step 2: Compile the generated procedure and deploy it in the propath. */
/************************** dbTableRecid.p ************************************/
DEFINE TEMP-TABLE ttRecidTable
FIELD cTableName AS CHARACTER
FIELD rRecordid AS RECID
INDEX RecordId IS PRIMARY rRecordid ASCENDING.
DEFINE INPUT PARAMETER ipcRecordNumber AS INTEGER NO-UNDO.
DEFINE OUTPUT PARAMETER opcTableName AS CHARACTER NO-UNDO.
FOR EACH Invoice NO-LOCK:
CREATE ttRecidTable.
ASSIGN
cTableName = "Invoice"
rRecordid = RECID(Invoice).
END.
FOR EACH Customer NO-LOCK:
CREATE ttRecidTable.
ASSIGN
cTableName = "Customer"
rRecordid = RECID(Customer).
END.
FOR EACH Item NO-LOCK:
CREATE ttRecidTable.
ASSIGN
cTableName = "Item"
rRecordid = RECID(Item).
END.
FOR EACH Order NO-LOCK:
CREATE ttRecidTable. .
ASSIGN
cTableName = "Order"
rRecordid = RECID(Order).
END.
FOR EACH Order-Line NO-LOCK:
CREATE ttRecidTable.
ASSIGN
cTableName = "Order-Line"
rRecordid = RECID(Order-Line).
END.
FOR EACH Salesrep NO-LOCK:
CREATE ttRecidTable.
ASSIGN
cTableName = "Salesrep"
rRecordid = RECID(Salesrep).
END.
FOR EACH State NO-LOCK:
CREATE ttRecidTable.
ASSIGN
cTableName = "State"
rRecordid = RECID(State).
END.
FOR EACH Local-Default NO-LOCK:
CREATE ttRecidTable.
ASSIGN
cTableName = "Local-Default"
rRecordid = RECID(Local-Default).
END.
FOR EACH Ref-Call NO-LOCK:
CREATE ttRecidTable.
ASSIGN
cTableName = "Ref-Call"
rRecordid = RECID(Ref-Call).
END.
FIND FIRST ttRecidTable WHERE
ttRecidTable.rRecordid = ipcRecordNumber
NO-LOCK NO-ERROR.
ASSIGN
opcTableName = ttRecidTable.cTableName.
RETURN.
/******************************************************************************/
/*Step 3: Use code similar to the following to get a listing of all the users */
/* their locked records and table names. */
/************************** dbTableRecid.p ************************************/
DEFINE VARIABLE cTableName AS CHARACTER NO-UNDO.
FOR EACH _Lock WHERE
_Lock._Lock-Usr <> ? AND
_Lock._Lock-Recid <> ?
NO-LOCK:
RUN dbTableRecid.p (INPUT _Lock._Lock-Recid ,OUTPUT cTableName).
MESSAGE
"User Number:" "~t" _Lock._Lock-Usr "~n"
"User Name:" "~t" _Lock._Lock-Name "~n"
"Record Id:" "~t" _Lock._Lock-Recid "~n"
"Table Name:" "~t" cTableName
VIEW-AS ALERT-BOX.
END.
.