Kbase 21760: 4GL -- How Many Records are There in a Query?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/7/2002 |
|
SUMMARY:
This Solution describes how to use the NUM-RESULTS attribute to find out how many records there are in a query.
EXPLANATION:
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.
SOLUTION:
In order to get all the table records in an open query, you must use the PRESELECT EACH statement instead of FOR EACH.
For more information about PRESELECT / FOR EACH, see Progress Knowledge Base Solution 16808.
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.
References to Written Documentation:
Progress Knowledge Base Solution 16808, "4GL Query Concepts ( FOR EACH , FIND , GET , INDEX )"