Consultor Eletrônico



Kbase P68335: How manyrRecords are there in a query (4GL)?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   03/02/2009
Status: Verified

GOAL:

How Many Records are there in a Query (4GL)?

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.x
OpenEdge 10.x
OpenEdge Category: Language (4GL/ABL)

FIX:

To know how many records are in a query you can use the NUM-RESULTS attribute. If the query has a browser however, the NUM-RESULTS attribute returns instead, the number of visible rows in the browser. When the browser is scrolled, more records are added to the query and the NUM-RESULTS value will change.

In order to get all the table records in an open query, you must use the PRESELECT EACH statement instead of FOR EACH.

Here are two examples of how to use PRESELECT EACH and NUM-RESULTS to
get the number of records in the query:

/* STATIC QUERY */
DEFINE QUERY Query1 FOR customer.

OPEN QUERY Query1 PRESELECT EACH customer NO-LOCK.

MESSAGE QUERY Query1:NUM-RESULTS VIEW-AS ALERT-BOX.


/* DYNAMIC QUERY */
DEFINE VARIABLE hQuery AS WIDGET-HANDLE.
DEFINE VARIABLE hBuffer AS WIDGET-HANDLE.
DEFINE VARIABLE hBrowse AS WIDGET-HANDLE.

CREATE BUFFER hBuffer FOR TABLE "Customer":U.

CREATE QUERY hQuery.
hQuery:SET-BUFFERS(hBuffer).


hQuery:QUERY-PREPARE("PRESELECT EACH " + hBuffer:NAME + " NO-LOCK":U).
hQuery:QUERY-OPEN.

MESSAGE hquery:NUM-RESULTS VIEW-AS ALERT-BOX.