Try OpenEdge Now
skip to main content
ABL Essentials
Procedure Blocks and Data Access : Language statements that define blocks : Data access without looping: the FIND statement : Index cursors
Index cursors
To understand better how the AVM navigates through a set of data, you need to understand the concept of index cursors. When you retrieve a record from the database using any of the statements you've seen in this chapter, the AVM keeps track of the current record position using an index cursor—a pointer to the record, using the location in the database indexes of the key value used for retrieval.
When you execute the statement FIND FIRST Customer, for example, the AVM sets a pointer to the record for Customer 1 within the CustNum index. If you execute the statement FIND FIRST Customer WHERE Country = "USA", the AVM points to Customer 1025 through the CountryPost index.
When you execute another FIND statement on the same table using one of the directional keywords, the AVM can go off in any direction from the current index cursor location, depending on the nature of the statement. By default, it reverts to the primary index. Here's an example that extends the previous one slightly:
FIND FIRST Customer NO-LOCK WHERE Customer.Country = "USA".
DISPLAY Customer.CustNum Customer.Name Customer.Country.

    DISPLAY Customer.CustNum Customer.Name FORMAT "x(20)" Customer.Country