NUM-RESULTS function
Returns, as an INTEGER value, the number of rows currently in the results list of a scrolling query. The results list is initialized when the query is opened. Depending on the query, the entire list is built immediately upon opening or it is gradually as needed.
Syntax
query-name
A character expression that evaluates to the name of a currently open, scrolling query. Ifquery-name
does not resolve to the name of a query, or if the query is not open or not scrolling, then the function returns the Unknown value (?
).Note: Searching for a query using a handle is more efficient than a character expression. The AVM resolves a character expression at run time by searching in the current routine for a static query with that name. If not found, the AVM searches the enclosing main procedure. If still not found, the AVM searches up through the calling programs of the current routine, and their main procedures. Since a handle uniquely identifies a query, no such search is required. Use the query object handle’s NUM-RESULTS attribute to avoid a run-time search.ExampleThe following example uses the NUM-RESULTS function in a message to report on the number of rows in a browse. Note that the query is opened with the PRESELECT option so that the entire results list is built immediately. Otherwise, NUM-RESULTS might not return the total number of rows in the browse. When you run this procedure and choose a button, the AVM selects certain rows within the browse and then reports on the number of rows selected and the total number of rows in the browse.
Notes
- To use the NUM-RESULTS function with a query, the query must be associated with a browse widget or you must define the query with the SCROLLING option. For more information on query definitions, see the reference entry for the DEFINE QUERY statement.
- If the query is empty, NUM-RESULTS returns 0.
- When possible, the AVM performs optimizations for GET LAST and REPOSITION statements. These optimizations make the results list invalid. At that point, NUM-RESULTS returns the Unknown value (
?
). These optimizations do not occur if the query is opened with the PRESELECT option or has an associated browse widget.See alsoCLOSE QUERY statement, CURRENT-RESULT-ROW function, DEFINE BROWSE statement, DEFINE QUERY statement, GET statement, NUM-RESULTS attribute, OPEN QUERY statement, QUERY-OFF-END function, REPOSITION statement
OpenEdge Release 10.2B
|