Kbase P17590: How to detect whether a record is locked with a share-lock
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  1/15/2009 |
|
Status: Verified
GOAL:
How to detect whether a record is locked with a share-lock
FACT(s) (Environment):
Windows
Progress 9.x
OpenEdge 10.x
FIX:
PROCEDURE GetCurrentProcessId EXTERNAL "KERNEL32.DLL":
DEFINE RETURN PARAMETER intProcessHandle AS LONG.
END PROCEDURE.
FUNCTION RecordShareLockedByAnotherUser RETURNS LOGICAL (aRecid AS RECID):
/*------------------------------------------------------------------*/
/* TRUE = Share-Lock Found, FALSE = No Share-Lock Found */
/*------------------------------------------------------------------*/
DEFINE VARIABLE intProcessHandle AS INTEGER NO-UNDO.
DEFINE VARIABLE intRecid AS INTEGER NO-UNDO.
RUN GetCurrentProcessId (OUTPUT intProcessHandle).
ASSIGN intRecid = INTEGER(aRecid).
FIND FIRST _Connect WHERE _Connect._Connect-Pid = intProcessHandle NO-LOCK NO-ERROR.
FOR EACH _Lock WHERE _Lock._Lock-Recid = intRecid NO-LOCK:
IF _Lock._Lock-Usr <> _Connect._Connect-Usr THEN
IF INDEX(_Lock._Lock-Flags,"S") > 0 OR INDEX(_Lock._Lock-Flags,"U") > 0 THEN
RETURN TRUE.
ELSE
RETURN FALSE.
END.
RETURN FALSE.
END FUNCTION.
FIND FIRST Customer SHARE-LOCK NO-WAIT.
DISPLAY "Current Contents of Comment Field " Customer.Comments FORMAT "x(50)".
IF AVAILABLE(Customer) = TRUE THEN
DO:
IF RecordShareLockedByAnotherUser(RECID(Customer)) = FALSE THEN
DO:
SET Customer.Comments.
DISPLAY ERROR-STATUS:GET-MESSAGE(1).
END.
ELSE
MESSAGE 'Someone Else Has The Record Locked With a Share-Lock' VIEW-AS ALERT-BOX.
END.