Is there a Progess abl way of only displaying a certain number of records, i.e. equivalent of rownum in SQL?

Solution 1:

Taking your request literally:

FOR EACH table_name NO-LOCK:
    display table_name.column_1 table.name.column_2
      with 10 down.
END.

Note: I removed an inappropriate comma between the field names.

You can also simply increment a counter and LEAVE when you have displayed N records.

Solution 2:

I'll just add this odd and rarely seen feature as well. At least in systems I've worked with it never seem to get much attention.

This will leave the FOR-loop after 10 iterations.

DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
FOR EACH table_name NO-LOCK iCounter = 1 TO 10:

    DISPLAY table_name.table_field iCounter. 

END.

Solution 3:

Just for the sake of completeness, the ProDataset supports only reading the first 10 rows with an auto-stop - not requiring the user to hit cancel after 10 or the programmer keeping a counter and leave as suggested by Tom Bascom.

DEFINE TEMP-TABLE ttCustomer NO-UNDO
    LIKE Customer .

DEFINE DATASET dsCustomer FOR ttCustomer .

DEFINE QUERY qCustomer FOR Customer .

DEFINE DATA-SOURCE srcCustomer FOR QUERY qCustomer .

QUERY qCustomer:QUERY-PREPARE ("for each Customer by Balance descending") .

BUFFER ttCustomer:ATTACH-DATA-SOURCE (DATA-SOURCE srcCustomer:HANDLE) .

BUFFER ttCustomer:BATCH-SIZE = 10 .

DATASET dsCustomer:FILL () .

FOR EACH ttCustomer BY ttCustomer.Balance DESCENDING:
    DISPLAY ttCustomer.CustNum 
            ttCustomer.Name
            ttCustomer.Balance .
END.