Firebird Documentation Index → Firebird 3.0.6 Release Notes → Procedural SQL (PSQL) → Scrollable (Bi-directional) Cursor Support |
Instead of just fetching rows sequentially in a forward direction, “scrollability” allows flexible navigation through an open cursor set both backwards and forwards. Rows next to, prior to and relative to the current cursor row can be targetted. In PSQL, a scrollable cursor can be operated on directly. API support is available to enable DSQL applications to fetch rows in a similar manner.
To declare a cursor:
DECLARE <name> SCROLL CURSOR FOR ( <select expression> )
To fetch forward:
FETCH <cursor name> [INTO <var name> [, <var name> ...]];
To fetch in any direction:
FETCH {NEXT | PRIOR | FIRST | LAST | ABSOLUTE <n> | RELATIVE <n>} FROM <cursor name> [INTO <var name> [, <var name> ...]];
See also Scrollable Cursor Support for DSQL in the chapter entitled [Changes to the Firebird API and ODS]. The section entitled Scrollable Cursor Usage explains a little more about the usage of the various FETCH options.
When a scrolling option is omitted, NO SCROLL is implied (i.e., the cursor is opened as forward-only). This means that only FETCH [NEXT FROM] commands can be used. Other commands will return an error.
Scrollable cursors are internally materialized as a temporary record set, thus consuming memory/disk resources, so this feature should be used only when really necessary.
Firebird Documentation Index → Firebird 3.0.6 Release Notes → Procedural SQL (PSQL) → Scrollable (Bi-directional) Cursor Support |