base.SqlHandle.fetchRelative

Fetches a row relative to the current row in a scrollable SQL result set.

Syntax

fetchRelative(
   position INTEGER)
  1. position is the row offset in the result set. The offset can be negative, to fetch backwards.

Usage

Call the fetchRelative() method to fetch the row at the specified offset, relative to the current row in a scrollable SQL result set.

The SQL statement must have been opened with a openScrollCursor() call.

After performing the fetch call, you can query for column information with the getResultCount(), getResultName(index), getResultType(index) and getResultValue(index) methods.

If no row is found (end of result set), SQLCA.SQLCODE is set to 100 (NOTFOUND).

If the result set is empty, or if no row exists at the specified offset relative to the current row position, SQLCA.SQLCODE is set to 100 (NOTFOUND).

As with standard Genero SQL instructions, SQL errors can be trapped with WHENEVER ERROR or TRY / CATCH blocks and by testing SQLCA.SQLCODE.

Example

DEFINE sh base.SqlHandle
...
CALL sh.fetchRelative(-3)

For a complete example, see Example 4: SqlHandle with scroll cursor.