Scrolling through previously retrieved data in embedded SQL applications

When an application retrieves data from the database, the FETCH statement allows you to scroll forward through the data. There is no equivalent SQL statement that you can use to scroll backwards through the result set. You can use the CLI and the Db2® JDBC Driver to run a backward FETCH through read-only scrollable cursors.

Procedure

For embedded SQL applications, you can use the following techniques to scroll through data that has been retrieved:

  • Keep a copy of the data that has been fetched in the application memory and scroll through it by some programming technique.
  • Use SQL to retrieve the data again, typically by using a second SELECT statement.