In the previous sections, how to update a column and insert a new row was explained. This section discusses how to modify the
ResultSet object by deleting a row. The method
deleteRow() is called to delete the row where the cursor is placed. For example, to delete the fourth row in the
ResultSet rs, the code looks like this:
rs.absolute(4); XResultSetUpdate updateRs = (XResultSetUpdate)UnoRuntime.queryInterface(XResultSetUpdate.class, rs); updateRs.deleteRow();
The fourth row is removed from
rs and also from the database.
The only issue about deletions is what the
ResultSet object does when it deletes a row. With some SDBC drivers, a deleted row is removed and no longer visible in a result set. Other SDBC drivers use a blank row as a placeholder (a "hole") where the deleted row used to be. If there is a blank row in place of the deleted row, the method
absolute() can be used with the original row positions to move the cursor, because the row numbers in the result set are not changed by the deletion.
Remember that different SDBC drivers handle deletions differently. For example, if an application is meant to run with different databases, the code should not depend on holes in a result set.
|Content on this page is licensed under the Public Documentation License (PDL).|