Count results in for-each

Rob Fitzpatrick

ProgressTalk.com Sponsor
You could count them yourself:
Code:
define variable i as integer no-undo.
for each table where condition:
  // stuff
  i = i + 1.
end.
display i.

For a scrolling query (subject to documented conditions), there is a num-results function. A dynamic query handle has a num-results attribute.

You can also look at the Log Manager's QryInfo log entry type. The docs show sample client log output.

Depending on how "results returned" is interpreted, you could also query the read statistics in the _UserTableStat VST before and after the FOR block. This will tell you how many records in that table were read by the storage engine for that user. Note that it isn't necessarily the number of records that satisfied the query predicate. You could write that code yourself, or install ProTop on your database server and let it show you _UserTableStat data in real time. It can be quite a useful tool for ABL programmers to look at data access.
 
You could count them yourself:
Code:
define variable i as integer no-undo.
for each table where condition:
  // stuff
  i = i + 1.
end.
display i.

For a scrolling query (subject to documented conditions), there is a num-results function. A dynamic query handle has a num-results attribute.

You can also look at the Log Manager's QryInfo log entry type. The docs show sample client log output.

Depending on how "results returned" is interpreted, you could also query the read statistics in the _UserTableStat VST before and after the FOR block. This will tell you how many records in that table were read by the storage engine for that user. Note that it isn't necessarily the number of records that satisfied the query predicate. You could write that code yourself, or install ProTop on your database server and let it show you _UserTableStat data in real time. It can be quite a useful tool for ABL programmers to look at data access.
Can I add i = 0 before the for each? lol
 
Top