1.1

Table Of Contents
Conicting Operations on page 173
Example of Forward-Only Updatable Result Set
Example of using ResultSet.updateXXX() + ResultSet.updateRow() to update a row:
Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
ResultSet uprs = stmt.executeQuery(
"SELECT FIRSTNAME, LASTNAME, WORKDEPT, BONUS " +
"FROM EMPLOYEE");
while (uprs.next()) {
int newBonus = uprs.getInt("BONUS") + 100;
uprs.updateInt("BONUS", newBonus);
uprs.updateRow();
}
Example of using ResultSet.deleteRow() to delete a row:
Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
ResultSet uprs = stmt.executeQuery(
"SELECT FIRSTNAME, LASTNAME, WORKDEPT, BONUS " +
"FROM EMPLOYEE");
while (uprs.next()) {
if (uprs.getInt("WORKDEPT")==300) {
uprs.deleteRow();
}
}
Visibility of Changes
After an update or delete is made on a forward-only result set, the result set's cursor is no longer on the row
just updated or deleted, but moves immediately before the next row in the result set. (It is necessary to move
to the next row before any further row operations are allowed.) This means that changes made by
ResultSet.updateRow() and ResultSet.deleteRow() are never visible.
If a row has been inserted (for example, using ResultSet.insertRow()), then it may be visible in a
forward-only result set.
Conflicting Operations
The current row of the result set cannot be changed by other transactions, because it will be locked with an update
lock. Result sets that are held open after a commit must move to the next row before allowing any operations
on it .
Some conicts may prevent the result set from doing updates and deletes. For example, if the current row is
deleted by a statement in the same transaction, then calls to ResultSet.updateRow() cause an exception
because the cursor is no longer positioned on a valid row.
Scrollable, Updatable Result Sets
A scrollable, updatable result set maintains a cursor that can both scroll and update rows.
SQLFire only supports Scrollable Insensitive Result Sets. To create a scrollable insensitive result set that is
updatable, you create the statement with concurrency mode ResultSet.CONCUR_UPDATABLE and type
ResultSet.TYPE_SCROLL_INSENSITIVE.
Examples of Scrollable, Updatable Result Sets on page 173
173
Using Result Sets and Cursors