Try OpenEdge Now
skip to main content
ABL Essentials
Using Queries : Defining and using queries
 

Defining and using queries

There is a DEFINE statement for a query as for other ABL objects. This is the general syntax:

Syntax

DEFINE QUERY query-name FOR buffer[ , ...][ SCROLLING ].
The statement gives the query a name and, in turn, names the buffer or buffers that the query uses. In the simplest case, the buffers are database table names. But you can also use other buffers you've defined as alternatives to table names or, as you'll learn later in this chapter, buffers for temp-tables.
If you want to reposition within the result set without using the GET FIRST, NEXT, PREV, and LAST statements, you need to define the query as SCROLLING. You'll learn later in this section how to reposition within the result set of a scrolling query. You must also define a query that is going to be associated with a browse as SCROLLING. There is a slight performance cost to using the SCROLLING option, so you should leave it off if you are not using the capabilities it enables.
You don't actually specify the exact data selection statement for the buffers and the tables they represent until you open the query. At that time, you can describe the joins between tables and any other parts of a WHERE clause that filter the data from the tables. As with other DEFINE statements, nothing actually happens when the ABL Virtual Machine (AVM) encounters the DEFINE QUERY statement. No data is retrieved. the AVM simply registers the query name and sets up storage and a handle for the query itself as an object.
* OPEN and CLOSE QUERY statements
* GET statements
* Closing a query
* Determining the current number of rows in a query
* Identifying the current row in the query
* Repositioning a query