skip to main content
OpenEdge Data Management: DataServer for ODBC
Programming Considerations : ABL issues : FIND statements : FIND PREV and FIND LAST statements
 
FIND PREV and FIND LAST statements
Applications that use the FIND PREV or FIND LAST statements work on tables in a manner consistent with the OpenEdge database. The only exception occurs when the FIND PREV or FIND LAST statement fails. In OpenEdge, the cursor is located after the last record that was scanned. In an ODBC data source, the cursor behaves as if the failed FIND had never occurred. To support these statements, a table must include support for the ROWID function (through either a PROGRESS_RECID column or an indexed NUMBER column with unique values). See ROWID function for more information.

find.p

For example, the procedure shown below accesses OpenEdge and ODBC data sources using the same FIND and FIND PREV statements in each case, as shown:
/* This code accesses an OpenEdge database. */
FIND demo.customer WHERE demo.customer.custnum = 3.
FIND PREV demo.customer.
DISPLAY demo.customer.custnum
LABEL "PROGRESS DATABASE RESULT" WITH FRAME new-frame.
/* This code accesses a MS SQL Server data source. */
FIND mssdemo.customer WHERE mssdemo.customer.custnum = 3.
FIND PREV mssdemo.customer.
DISPLAY mssdemo.customer.custnum
LABEL "MSS DATA SOURCE RESULT" WITH COL 29.
When you run find.p with an OpenEdge table and a MS SQL Server table, you get the following results (assuming that the database has records for customer numbers 1 through 4):
If the FIND PREV statement fails, the cursor remains located after customer.custnum 3 in the OpenEdge table, which was the last record scanned. In the data source table, the cursor is positioned at custnum 2. Failed finds do not affect cursor position in data source tables.