Determining the current number of rows in a query
- Last Updated: March 30, 2020
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
You can use the NUM-RESULTS function to
determine how many rows there are in the current results list:
|
This INTEGER function returns the number of
rows currently in the query's results list. As with the QUERY-OFF-END function,
the query-name is an expression, which can be
either the quoted name of the query or a variable containing the
name.
The phrase "currently in the query's results list" requires some explanation. The results list is a list of the row identifiers of all rows that satisfy the query, and that have already been retrieved.
The AVM normally builds up the results list as you walk through
the query using the GET statement. Therefore, when
you first open a query with a FOR EACH clause in
the OPEN QUERY statement, the results list is empty
and the NUM-RESULTS function returns zero.
As you move through the query using the GET NEXT statement,
the AVM adds each new row's identifier to the results list and increments
the value returned by NUM-RESULTS. For example, this
example retrieves all the Customers in the
state of Louisiana using a query. For each row, it displays the Customer Number, Name,
and the value of NUM-RESULTS:
|
When you run the procedure, you see the value of NUM-RESULTS change
as each new row is retrieved, as shown in the following figure.
