Consultor Eletrônico



Kbase P92923: How to find the maximum record size held in a table with 4GL ?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/11/2008
Status: Verified

GOAL:

How to find the maximum record size held in a table with 4GL ?

GOAL:

How to find the recid of the largest record in a table ?

GOAL:

How many fragments is a record made up of ?

FACT(s) (Environment):

All Supported Operating Systems
Progress/OpenEdge Product Family

FIX:

In addition to the record-length of the largest recid found in a table, the following code gives additional information for the "bytes read". This implies that when running this code online, this is the ONLY read taking place for the value to be equal to the RECORD-LENGTH as the _actrecord VST table does not differentiate between one record and the next. It does however provide an example of how to check the bytes-read records-read and fragments-read against the record-length in a FIND statement.

/*
NOTE:
_actrecord is for ALL record reads since dbstartup so we have subtract the total from THIS record read.
The following code runs against the sports2000 database for the customer table.
*/

DEF VAR Record-BytesRead LIKE _actrecord._Record-BytesRead.
DEF VAR Record-FragRead LIKE _actrecord._Record-FragRead.
DEF VAR Record-RecRead LIKE _actrecord._Record-RecRead.

DEFINE VARIABLE maxRecid AS RECID NO-UNDO.
DEFINE VARIABLE maxLength AS INTEGER NO-UNDO.

FIND FIRST customer USE-INDEX custnum.
ASSIGN maxRecid = RECID(customer)
maxLength = RECORD-LENGTH(customer).

FOR EACH customer USE-INDEX custnum:
IF RECORD-LENGTH(customer) GT maxLength THEN DO:
ASSIGN maxRecid = RECID(customer).
ASSIGN maxLength = RECORD-LENGTH(customer).
END.
END.

FIND FIRST _ActRecord.
Record-BytesRead = _actrecord._Record-BytesRead.
Record-FragRead = _actrecord._Record-FragRead.
Record-RecRead = _actrecord._Record-RecRead.

FIND FIRST customer WHERE RECID(customer) = maxRecid.

FIND FIRST _ActRecord.
Record-BytesRead = _actrecord._Record-BytesRead - Record-BytesRead.
Record-FragRead = _actrecord._Record-FragRead - Record-FragRead.
Record-RecRead = _actrecord._Record-RecRead - Record-RecRead.

DISPLAY Record-RecRead maxRecid maxLength Record-BytesRead Record-FragRead WITH SIDE-LABELS.