Consultor Eletrônico



Kbase P28068: Is there a VST storing the number of records within a table?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/10/2008
Status: Unverified

GOAL:

Is there a VST storing the number of records within a table?

GOAL:

Quickest way to count records with 4GL program

FIX:

There is no VST which contains the number of records within a table.

Within the two samples below, the FIELD() option will give better performance in client/server configurations.

/* FOR EACH example, with ACCUM and COUNT functions. */
/* ACCUM should be on one of the primary index fields (custNum here) */

DEFINE VARIABLE A AS INTEGER NO-UNDO.
A = ETIME(YES).
FOR EACH customer FIELD() NO-LOCK:
ACCUM customer.custNum (COUNT).
END.
MESSAGE "TOTAL OF RECORDS = " (ACCUM COUNT customer.custNum) SKIP(1)
"TIME FOR PROCESSING = " ETIME VIEW-AS ALERT-BOX.


/* QUERY example */
DEFINE VARIABLE A AS INTEGER NO-UNDO.
DEFINE QUERY MYQUERY FOR CUSTOMER FIELD() SCROLLING.

A = ETIME(YES).
OPEN QUERY MYQUERY FOR EACH CUSTOMER NO-LOCK.

REPEAT WHILE NOT QUERY-OFF-END("MYQUERY"):
GET NEXT MYQUERY.
END.

MESSAGE "TOTAL OF RECORDS = " NUM-RESULTS("MYQUERY") SKIP(1)
"TIME FOR PROCESSING = " ETIME VIEW-AS ALERT-BOX.