Identify the current row in the query
- Last Updated: April 2, 2024
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
As you move through the results list, the AVM keeps
track of the current row number, that is, the sequence of the row
in the results list. You can retrieve this value using the CURRENT-RESULT-ROW function:
|
The function returns an INTEGER value with the sequence
of the current row. The query-name is an expression,
either a quoted query name or a variable reference.
For CURRENT-RESULT-ROW to work properly, you
must define the query to be SCROLLING. If you do not define
the query as SCROLLING, the CURRENT-RESULT-ROW function returns a value, but that value is not reliable.
To use CURRENT-RESULT-ROW, make these changes
to your sample procedure:
|
When you run the procedure, you see that the value of CURRENT-RESULT-ROW keeps
pace with NUM-RESULTS, as shown in the following
figure.
This is not always the case, of course. If you use the PRESELECT option
or a nonindexed sort to retrieve the data, then NUM-RESULTS is
always 13, as you have seen. But the value of CURRENT-RESULT-ROW changes
from 1 to 13 just as it does above.
You can use the CURRENT-RESULT-ROW function to
save off a pointer to reposition to a specific row. See Use a RowID to identify a record for information on how to identify a record.
Here are a few special cases for CURRENT-RESULT-ROW:
- If the query is empty, the function returns the Unknown value (
?). - If the query is explicitly positioned before the first row,
for example by executing a
GET FIRSTfollowed by aGET PREV, then the function returns the value 1. - If the query is explicitly positioned after the last row, for
example by executing a
GET LASTfollowed by aGET NEXT, then the function returns the value one more than the number of rows in the results list.