6 Scrolling Cursors

Commonly, a result set is scanned from the beginning to the end. Sometimes, however, other orders of fetching of results are desirable. Scrolling result sets support this.

To use scrolling cursors and result sets, include the fragment scrollingresultset. Applications can investigate whether a connection supports scrolling cursors by calling scrollingCursorsSupported on a connection.

Suppose the connection con supports scrolling cursors. Then the declaration of a statement stmt as

stmt: @con.directSQLStatement
        (#
           cursorType::
             (# scrollable::  (#  do true->value #) #);
           resultSetType:: con.scrollingResultSet
         #)
will create a scrolling result set whenever stmt is executed:
rs: ^connection.scrollingResultSet;
...
do ...; stmt.execute->rs[]; ...
The result set, rs, may now be used to scroll through the result set using the methods shown below.
scrollingResultSet: resultSet
  (#
     fetchFirst: ...;
     fetchLast: ...;
     fetchNext: ...;
     fetchPrior: ...;
     fetchRelative: ...;
     fetchAbsolute: ...;
     scanReverse: ...;
     ...
  #)
fetchLast, for example, will fetch the last tuple in the result set and scanReverse will scan through the result set backwards.

Please note that it is not possible to use both fetch and the methods declared on scrollingResultSet on the same result set.


The BetaDBC Library - Reference Manual and Tutorial
© 1999-2004 Mjølner Informatics
[Modified: Friday September 7th 2001 at 12:45]