Use queries to share data between procedures

A query is also a true object in ABL. It has a definition and a name, and you can use the name to access it anywhere in your procedure. You have already learned a little about handles, which give you a reference to an object that you can pass from procedure to procedure. Using a query's handle, you can access the query and its result set from anywhere in your application session. This gives you the ability to modularize your application in ways that cannot be done with block-oriented result sets, which are not named objects and which have no meaning or visibility outside their defined scope. You learn a lot more about how to use a query's handle to access its data in later chapters that discuss dynamic data retrieval language.

Use queries to populate a browse

A query is the basis for the data definition for a browse object. You cannot populate a browse with the data from a FOR EACH block, only from a query. The browse gives you a viewport into the query. The repositioning you can do by selecting a record in the browse or scrolling through its contents reflects the repositioning that you can do programmatically through the query. In fact, selecting a row in a browse automatically repositions the query to that row, making it the current row in the buffers the query uses.