Kbase P107604: How to count the number of records displayed in a 4GL browse?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  7/18/2007 |
|
Status: Unverified
GOAL:
How to count the number of records displayed in a 4GL browse?
FIX:
How to do this depends on exactly what is required, the circumstances and the options set for the browse. For example with a standard 4GL browse this can be done easily with the browse query NUM-RESULTS attribute and the GET-LAST method. For example:
h_Browse = browse-1:QUERY.
h_query:GET-LAST().
MESSAGE h_query:NUM-RESULTS.
But this only works if INDEXED-REPOSITION is switched off for the browse query.
If you have access to the query definition, another method is to use PRESELECT with the OPEN-QUERY statement:
OPEN QUERY qResults PRESELECT EACH Customer FIELDS NO-LOCK.
MESSAGE NUM-RESULTS ( "qResults" ) VIEW-AS ALERT-BOX INFORMATION.
CLOSE QUERY qResults.
PRESELECT can also be used with a dynamic query, for example:
DEFINE VARIABLE cBaseQuery AS CHARACTER NO-UNDO INITIAL "PRESELECT EACH Customer NO-LOCK".
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE hCustomerBuffer AS HANDLE NO-UNDO.
CREATE BUFFER hCustomerBuffer FOR TABLE "Customer".
CREATE QUERY hQuery.
hQuery:SET-BUFFERS(hCustomerBuffer).
hQuery:QUERY-PREPARE(cBaseQuery).
hQuery:QUERY-OPEN.
If you want to display the record count in a browse column, then this can be very difficult because of the restrictions placed on the ROW-DISPLAY trigger that result in error 5906.
However, the most flexible method is to create a query as a separate object and the associate it with the browse later. This way the query can be manipulated and a dynamic browse used to display the results which could include the record count as a regular browse column.