Moving the Result Set Cursor

From Apache OpenOffice Wiki
Jump to: navigation, search

The ResultSet stored in the variable xResult contains the following data after the call above:

Joseph Smith 02/07/46
Bob Meyers 09/07/49

To access the data, go to each row and retrieve the values according to their types. The method next() is used to move the row cursor from row to row. Since the cursor is initially positioned just above the first row of a ResultSet object, the first call to next() moves the cursor to the first row and makes it the current row. For the same reason, use the method next() to access the first row even if there is only one row in a result set. Subsequent invocations of next() move the cursor down one row at a time.

The interface offers methods to move to specific row numbers, and to positions relative to the current row, in addition to moving the cursor back and forth one row at a time:

  // move one row at a time
  boolean next()
  boolean previous()
  // move a number of rows
  boolean absolute( [in] long row )
  boolean relative( [in] long rows )
  // move to result set borders and beyond
  boolean first()
  boolean last()
  void beforeFirst()
  void afterLast()
  //detect position
  boolean isBeforeFirst()
  boolean isAfterLast()
  boolean isFirst()
  boolean isLast()
  long getRow()
  // refetch row from the database
  void refreshRow()
  // row has been updated, inserted or deleted
  boolean rowUpdated()
  boolean rowInserted()
  boolean rowDeleted()
  // get the statement which created the result set
  com::sun::star::uno::XInterface getStatement()
Documentation note.png Note that you can only move the cursor backwards if you set the statement property ResultSetType to SCROLL_INSENSITIVE or SCROLL_SENSITIVE. For details, refer to chapter Scrollable Result Sets.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages