Consultor Eletrônico



Kbase P6091: How to loop through all the records of a static 4GL query?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/03/2003
Status: Unverified

GOAL:

How to loop through all the records of a static 4GL query?

FIX:

You can loop through the records of a a static Query using either the REPEAT or the DO WHILE construct. The following code samples illustrate both:

/* 1. Using the REPEAT loop construct */

DEFINE QUERY myQuery FOR myTableName.
OPEN QUERY myQuery FOR EACH myTableName.

REPEAT:
GET NEXT myQuery.
IF NOT AVAILABLE (myTableName) THEN LEAVE.
DISPLAY myTableName.myFieldName.
END.


/* 2. Using the DO WHILE loop construct */

DEFINE QUERY myQuery FOR myTableName.
OPEN QUERY myQuery FOR EACH myTableName.

GET FIRST myQuery.
DO WHILE AVAILABLE(myTableName):
DISPLAY myTableName.myFieldName.
GET NEXT myQuery.
END.