Kbase P110815: 4GL/ABL: How to programmatically count table records using "proutil -C tabanalys" command?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  01/12/2008 |
|
Status: Verified
GOAL:
4GL/ABL: How to programmatically count table records using "proutil <dbname> -C tabanalys" command?
GOAL:
How to count table records using 4GL and the "proutil <dbname> -C tabanalys" command?
GOAL:
How to parse the output of the "proutil <dbname> -C tabanalys" command using 4GL/ABL to obtain the record count for each data table?
FACT(s) (Environment):
All Supported Operating Systems
Progress 9.x
OpenEdge 10.x
FIX:
The following code does the following:
A. Executes the "proutil <dbname> -C tabanalys" command against the sports2000 database.
B. Parses the output file to extract the record count of all user data tables. This code ignores system and VST tables. It may be extended to include the _User or any other VST table of interest.
DEFINE VARIABLE cCommandLine AS CHARACTER NO-UNDO.
DEFINE VARIABLE cRawDataFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTempDataFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFinalReportFile AS CHARACTER NO-UNDO.
ASSIGN
cRawDataFile = "RawData.out"
cTempDataFile = "TempData.out"
cFinalReportFile = "FinalReport.out"
cCommandLine = "proutil sports2000 -C tabanalys > " + cRawDataFile.
/* Execute the proutil command and send its output to "tabanalysis.out" */
OS-COMMAND SILENT VALUE(cCommandLine).
RUN GenerateTempDataFile.
RUN GenerateFinalReportFile.
/* Generate intermediate file containing info lines on all tables owned by PUB */
PROCEDURE GenerateTempDataFile.
DEFINE VARIABLE cLine AS CHARACTER NO-UNDO.
INPUT FROM VALUE(cRawDataFile).
OUTPUT TO VALUE(cTempDataFile).
REPEAT:
IMPORT UNFORMATTED cLine.
IF cLine BEGINS "PUB." THEN DO:
cLine = REPLACE ( cLine , "PUB." ,"").
PUT UNFORMATTED cLine SKIP.
END.
END.
INPUT CLOSE.
OUTPUT CLOSE.
END PROCEDURE.
/* Generate final report by extracting the first two fields of the intermediate file */
PROCEDURE GenerateFinalReportFile.
DEFINE VARIABLE cTableName AS CHARACTER NO-UNDO.
DEFINE VARIABLE iNumberOfRecords AS INTEGER NO-UNDO.
INPUT FROM VALUE(cTempDataFile).
OUTPUT TO VALUE(cFinalReportFile).
REPEAT:
IMPORT DELIMITER " " cTableName iNumberOfRecords.
PUT UNFORMATTED
cTableName AT 1
iNumberOfRecords TO 25 SKIP.
END.
INPUT CLOSE.
OUTPUT CLOSE.
END PROCEDURE.