FETCH with a Scroll Cursor

These examples illustrate the FETCH statement with a scroll cursor:
EXEC SQL fetch previous q_curs into :orders;
EXEC SQL fetch last q_curs into :orders;
EXEC SQL fetch relative -10 q_curs into :orders;
printf("Which row? ");
scanf(" 
EXEC SQL fetch absolute :row_num q_curs into :orders;

A scroll cursor can fetch any row in the active set, either by specifying an absolute row position or a relative offset. Use the following cursor-position options to specify a particular row that you want to retrieve.

Keyword
Effect
NEXT
Retrieves next row in active set
PREVIOUS
Retrieves previous row in active set
PRIOR
Retrieves previous row in active set (Synonymous with PREVIOUS.)
FIRST
Retrieves the first row in active set
LAST
Retrieves the last row in active set
CURRENT
Retrieves the current row in active set (the same row as returned by the previous FETCH statement from the scroll cursor)
RELATIVE
Retrieves nth row, relative to the current cursor position in the active set, where position_num (or position_num_var) supplies n. A negative value indicates the nth row prior to the current cursor position. If position_num = 0, the current row is fetched.
ABSOLUTE
Retrieves nth row in active set, where row_position_var (or row_position) = n . Absolute row positions are numbered from 1.
Tip: Do not confuse row-position values with rowid values. A rowid value is based on the position of a row in its table and remains valid until the table is rebuilt. A row-position value (a value that the ABSOLUTE keyword retrieves) is the relative position of the row in the current active set of the cursor; the next time the cursor is opened, different rows might be selected.