Consultor Eletrônico



Kbase P112624: 4GL/ABL: How to determine whether a database is in single-user mode, multi-user mode, or is in use b
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   02/12/2008
Status: Verified

GOAL:

4GL/ABL: How to determine whether a database is in single-user mode, multi-user mode, or is in use by a Progress utility?

GOAL:

How to use the Progress PROUTIL utility to determine whether a database is in single-user mode, multi-user mode, or is in use by a Progress utility.

GOAL:

How to access the PROUTIL HOLDER qualifier return codes from 4GL?

GOAL:

How To Access PROUTIL's HOLDER qualifier return codes from DOS or 4GL?

FACT(s) (Environment):

Windows
Progress 9.x
OpenEdge 10.x

FIX:

When the PROUTIL utility is executed with the HOLDER qualifier, it returns a code that determines the status of the database. The Progress Database Administration Guide and Reference provides a UNIX script example demonstrating the capture of these return codes. This solution provides a DOS batch file example showing how to access these return codes from the DOS command line, and a 4GL procedure demonstrating how to determine the status of a database using 4GL. The HOLDER qualifier returns the following values:
0 if the Database is not in use.
14 if the Database is locked by a single user, the PROUTIL utility or the RFUTIL utility.
16 if the Database is open in multi-user mode.
1. Accessing the HOLDER qualifier return codes using the DOS command line:
1.1. Cut, paste, and save the following batch file as "DBHolder.bat". Edit the DB-NAME and DLC environment variables to reflect your environment:
@ECHO OFF
SET DB-NAME=C:\WRK91E\Sports2000
SET DLC=C:\PROGRESS91E
%DLC%\BIN\_PROUTIL %DB-NAME% -C HOLDER > NUL
IF ERRORLEVEL 16 GOTO MULTIUSER
IF ERRORLEVEL 14 GOTO SINGLEUSER
IF ERRORLEVEL 0 GOTO NOTINUSE
GOTO END
:MULTIUSER
ECHO Database is open in multi-user mode
GOTO END
:SINGLEUSER
ECHO Database is locked by single user, PROUTIL, or RFUTIL
GOTO END
:NOTINUSE
ECHO Database is not in use
GOTO END
:END

1.2. Execute the DBHolder.bat batch file from the DOS command.

2. Determining the status of a database using 4GL:
2.1. Cut, paste, and save the following batch file as "DBStatus.bat". Edit the DB-NAME and DLC environment variables to reflect your environment:
@ECHO OFF
SET DB-NAME=C:\WRK91E\Sports2000
SET DLC=C:\Progress91E
%DLC%\bin\_proutil %DB-NAME% -C holder
ECHO %ERRORLEVEL% > TempFilename.txt

2) Run the following 4GL procedure:
DEFINE VARIABLE cTempFilename AS CHARACTER NO-UNDO.
DEFINE VARIABLE cOutputLine AS CHARACTER NO-UNDO.
DEFINE VARIABLE cExecutableCommand AS CHARACTER NO-UNDO.
ASSIGN
cExecutableCommand = "DBStatus.bat"
cTempFilename = "TempFilename.txt".

OS-COMMAND SILENT VALUE(cExecutableCommand).
INPUT FROM VALUE( cTempFilename ) NO-ECHO.
IMPORT UNFORMATTED cOutputLine.
IF cOutputLine = "16" THEN
MESSAGE "Database is open in multi-user mode"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
IF cOutputLine = "14" THEN
MESSAGE "Database is locked by single user, PROUTIL, or RFUTIL"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
IF cOutputLine = "0" THEN
MESSAGE "Database is not in use"
VIEW-AS ALERT-BOX INFO BUTTONS OK.