Try OpenEdge Now
skip to main content
DataServer for Microsoft SQL Server
Initial 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 the MS SQL Server data source, the cursor behaves as if the failed FIND had never occurred. To support these statements, a table must include support for the OpenEdge ROWID function (through either a PROGRESS_RECID column or an indexed NUMBER column with unique values). See ROWID function for more information.
For example, the procedure find.p accesses OpenEdge and MS SQL Server databases 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 EQ 3.
FIND PREV demo.customer.
DISPLAY demo.customer.custnum

/* This code accesses a MS SQL Server data source.*/
FIND mssdemo.customer WHERE mssdemo.customer.custnum EQ 3.
FIND PREV mssdemo.customer.
DISPLAY mssdemo.customer.custnum
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.