Progress
Language Tutorial
for Windows
Using Defined Queries
Progress has another statement that works similarly to FIND: the GET statement. To put it simply, FIND returns a record from the database and GET returns a record from the database by way of a defined query. So before you can use GET, you need to learn about defined queries.
A defined query lets you build a results list of records that satisfy some criteria. When you use FIND, Progress only knows about a single record that satisfies your criteria. When you use a defined query, Progress knows about all the records that satisfy the criteria. This results list is the basis for many Progress features.
In the context of an interactive database form, these steps show how to program a defined query:
- Established the query with the DEFINE QUERY statement at the top of the procedure in the definitions section.
- Initialize the results list with the OPEN QUERY statement at the beginning of your main code block.
- Navigate through the results list with the GET statement, or by using a browse widget, but not with both.
- Release the query resources with the CLOSE QUERY statement at the end of your main code block.
To start with, the DEFINE QUERY statement lets you name your new query and requires you to list all the tables that the query uses. This is a partial syntax for the DEFINE QUERY statement.
Use the SCROLLING option if you plan to use a browse widget or the REPOSITION statement with the query. SCROLLING is almost always necessary for an interactive database procedure.
Next, you need to initialize the results list with the OPEN QUERY statement. This is a partial syntax for the OPEN QUERY statement.
Each instance of the FIND statement uses a record phrase. With a defined query, the record phrase does its work up front in the OPEN QUERY statement. Therefore, the GET statement has no need to support the record phrase.
Now, you’re ready to navigate through the results list. The next few sections of this chapter show you how to do this.
Finally, when you finish working with a query, you should close it. This is the syntax for the CLOSE QUERY statement.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |