Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting first 100 records from the table in Progress OpenEdge database (e.g. SELECT TOP 100..)

How can I get a limited number of records from the table in Progress OpenEdge database?

Something like in SQL:

SELECT TOP 100 * FROM MyTable

The only ugly solution I can find is looping through all records and breaking when 100 of them were displayed. But feels like there should be some better way of doing it.

like image 857
Daria Trainor Avatar asked Oct 07 '11 05:10

Daria Trainor


1 Answers

If you are using the 4GL you might also want to look at using OPEN QUERY and MAX-ROWS to achieve the result that you are looking for. The following shows a traditional FOR EACH loop with a counter and then a QUERY with MAX-ROWS:

define variable i as integer no-undo.
define frame a with 10 down.

for each customer no-lock break by name:
  i = i + 1.
  display i custNum name discount.
  if i >= 5 then leave.
end.

define query q for customer scrolling.

open query q for each customer no-lock break by name max-rows 5.

do i = 1 to 5 with frame a:
  get next q.
  display i custNum name discount.
end.
like image 80
Tom Bascom Avatar answered Nov 08 '22 22:11

Tom Bascom