Using Result Sets to Modify Data

In many types of applications, users will scroll through a set of data before deciding when to update a record. The update could involve changing a value in a column or deleting an entire row. Using traditional result sets returned from an executeQuery() operation, an application can list all of the rows that are returned from a table. Unfortunately, these rows can't be updated dynamically, so the application would have to issue an UPDATE or a DELETE statement against the current row. The program would need logic similar to the following example:

 rs = s.executeQuery("SELECT * FROM TESTCURSOR"); while (rs.next()) { ... populate display with all records found ... } ... user selects a record to delete ... rs = s.executeUpdate("DELETE ...

Get Apache Derby—Off to the Races: Includes Details of IBM® Cloudscape™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.