Kbase P20194: 4GL/ABL: How to determine if a PERSISTENT Procedure is running given its Program Name?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  26/02/2009 |
|
Status: Verified
GOAL:
4GL/ABL: How to determine if a PERSISTENT Procedure is running given its Program Name?
GOAL:
How to ensure that a given procedure is not run PERSISTENT if it is already running?
GOAL:
How not to run a PERSISTENT procedure if it is already running?
FACT(s) (Environment):
All Supported Operating Systems
Progress 9.x
OpenEdge 10.x
FIX:
The following code scans the session PERSISTENT procedures to see if the "ProgramName.w" is already running PERSISTENTly. If it is running, its "InternalProcedureName" is called. Otherwise it is run as a PERSISTENT procedure and then its internal procedure "InternalProcedureName" is called:
DEFINE VARIABLE hProcedureHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE cProgramName AS CHARACTER NO-UNDO.
ASSIGN
cProgramName = "ProgramName.w"
hProcedureHandle = SESSION:FIRST-PROCEDURE NO-ERROR.
DO WHILE VALID-HANDLE(hProcedureHandle):
IF hProcedureHandle:FILE-NAME = cProgramName THEN LEAVE.
hProcedureHandle = hProcedureHandle:NEXT-SIBLING NO-ERROR.
END.
IF VALID-HANDLE(hProcedureHandle) THEN
RUN InternalProcedureName IN hProcedureHandle.
ELSE DO:
RUN VALUE(cProgramName) PERSISTENT SET hProcedureHandle.
RUN InternalProcedureName IN hProcedureHandle.
END.