Getting the first 100 records from a table in an OpenEdge Progress database (for example, SELECT TOP 100 ..)

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

Something like SQL:

SELECT TOP 100 * FROM MyTable 

The only ugly solution I can find is to loop through all the records and break when 100 of them were displayed. But feels that there must be a better way to do this.

+4
source share
4 answers

If you use 4GL, you may also need to use OPEN QUERY and MAX-ROWS to achieve the result you are looking for. The following is a traditional FOR EACH loop with a counter, followed by 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. 
+6
source

If you use the SQL-92 engine, then something like:

SELECT TOP 100 FROM pub.customer;

should work fine.

If you use a 4GL engine, you should not try to mix SQL with 4GL. This will only lead to pain, suffering and torment. 4GL is not SQL. There are several SQL-89 statements that were added to 4GL a long time ago for marketing reasons. Attempting to use them will result in severe emotional trauma. You have been warned.

+6
source

Follow the link to download the file. Hoping the question will be answered by OpenEdge Database

0
source

DEFINITION OF A VARIABLE AND AS INTEGER NO-UNDO.

FOR EVERY NO-LOCK client with a width of 320:

 ASSIGN i = i + 1. 

if I <= 100, then DISP CustNum Address Balance City Contact Country CreditLimit Discount
Name Telephone Postal Code SalesRep Terms of Use.

END.

-1
source

All Articles