Consultor Eletrônico



Kbase P12564: 4GL/ABL: How to check the number of rows returned by a QUERY?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   3/5/2009
Status: Verified

GOAL:

4GL/ABL: How to check the number of rows returned by a QUERY?

GOAL:

How to know the number of records returned by a static 4GL/ABL QUERY?

GOAL:

How to determine the number of rows returned by a dynamic 4GL/ABL QUERY?

GOAL:

How to use the NUM-RESULTS function and the NUM-RESULTS attribute?

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x

FIX:

1. If the query is a static query defined with the SCROLLING option or is associated with a browse widget, then use the NUM-RESULTS function to get the number of rows currently in the query?s result list. Depending on the query, the entire list is built immediately upon opening or it is gradually as needed. When the query is opened with the PRESELECT option, the entire results list is built immediately. For example, the following statement displays the number of rows currently in the static query ("QueryName"):

MESSAGE NUM-RESULTS ("QueryName")
VIEW-AS ALERT-BOX INFO BUTTONS OK.

2. If the query is a dynamic query and hQuery is its handle, then use the NUM-RESULTS attribute to get the number of rows currently in the query?s result list. For example, the following code snippet checks whether the dynamic query returned any rows or not:

IF hQuery:NUM-RESULTS = 0 THEN
MESSAGE ?This Query returns no results?
VIEW-AS ALERT-BOX.