Oracle8i JDBC Developer's Guide and Reference Release 3 (8.1.7) Part Number A83724-01 |
|
This section discusses the ability of a result set to see the following:
DELETE
, UPDATE
, or INSERT
operations within the result set), referred to as internal changes
Near the end of the section is a summary table.
The ability of an updatable result set to see its own changes depends on both the result set type and the kind of change (UPDATE
, DELETE
, or INSERT
). This is discussed at various points throughout the "Updating Result Sets" section beginning on , and is summarized as follows:
DELETE
operations are visible for scrollable result sets (scroll-sensitive or scroll-insensitive), but are not visible for forward-only result sets.
After you delete a row in a scrollable result set, the preceding row becomes the new current row, and subsequent row numbers are updated accordingly.
UPDATE
operations are always visible, regardless of the result set type (forward-only, scroll-sensitive, or scroll-insensitive).
INSERT
operations are never visible, regardless of the result set type (neither forward-only, scroll-sensitive, nor scroll-insensitive).
An internal change being "visible" essentially means that a subsequent getXXX()
call will see the data changed by a preceding updateXXX()
call on the same data item.
JDBC 2.0 DatabaseMetaData
objects include the following methods to verify this. Each takes a result set type as input (ResultSet.TYPE_FORWARD_ONLY
, ResultSet.TYPE_SCROLL_SENSITIVE
, or ResultSet.TYPE_SCROLL_INSENSITIVE
).
boolean ownDeletesAreVisible(int) throws SQLException
boolean ownUpdatesAreVisible(int) throws SQLException
boolean ownInsertsAreVisible(int) throws SQLException
Only a scroll-sensitive result set can see external changes to the underlying database, and it can only see the changes from external UPDATE
operations. Changes from external DELETE or INSERT
operations are never visible.
For implementation details of scroll-sensitive result sets, including exactly how and how soon external updates become visible, see "Oracle Implementation of Scroll-Sensitive Result Sets".
JDBC 2.0 DatabaseMetaData
objects include the following methods to verify this. Each takes a result set type as input (ResultSet.TYPE_FORWARD_ONLY
, ResultSet.TYPE_SCROLL_SENSITIVE
, or ResultSet.TYPE_SCROLL_INSENSITIVE
).
boolean othersDeletesAreVisible(int) throws SQLException
boolean othersUpdatesAreVisible(int) throws SQLException
boolean othersInsertsAreVisible(int) throws SQLException
Explicit use of the
Note:
refreshRow()
method, described in "Refetching Rows", is distinct from this discussion of visibility. For example, even though external updates are "invisible" to a scroll-insensitive result set, you can explicitly refetch rows in a scroll-insensitive/updatable result set and retrieve external changes that have been made. "Visibility" refers only to the fact that the scroll-insensitive/updatable result set would not see such changes automatically and implicitly.
Regarding changes made to the underlying database by external sources, there are two similar but distinct concepts with respect to visibility of the changes from your local result set:
A change being "visible" means that when you look at a row in the result set, you can see new data values from changes made by external sources to the corresponding row in the database.
A change being "detected", however, means that the result set is aware that this is a new value since the result set was first populated.
With Oracle8i release 8.1.6 and higher, even when an Oracle result set sees new data (as with an external UPDATE
in a scroll-sensitive result set), it has no awareness that this data has changed since the result set was populated. Such changes are not "detected".
JDBC 2.0 DatabaseMetaData
objects include the following methods to verify this. Each takes a result set type as input (ResultSet.TYPE_FORWARD_ONLY
, ResultSet.TYPE_SCROLL_SENSITIVE
, or ResultSet.TYPE_SCROLL_INSENSITIVE
).
boolean deletesAreDetected(int) throws SQLException
boolean updatesAreDetected(int) throws SQLException
boolean insertsAreDetected(int) throws SQLException
It follows, then, that result set methods specified by JDBC 2.0 to detect changes--rowDeleted()
, rowUpdated()
, and rowInserted()
--will always return false with the 8.1.6 Oracle JDBC drivers. There is no use in calling them.
Table 12-1 summarizes the discussion in the preceding sections regarding whether a result set object in the Oracle JDBC implementation can see changes made internally through the result set itself, and changes made externally to the underlying database from elsewhere in your transaction or from other committed transactions.
For implementation details of scroll-sensitive result sets, including exactly how and how soon external updates become visible, see "Oracle Implementation of Scroll-Sensitive Result Sets".
Notes:
|
The Oracle implementation of scroll-sensitive result sets involves the concept of a window, with a window size that is based on the fetch size. The window size affects how often rows are updated in the result set.
Once you establish a current row by moving to a specified row (as described in "Positioning in a Scrollable Result Set"), the window consists of the N rows in the result set starting with that row, where N is the fetch size being used by the result set (see "Fetch Size"). Note that there is no current row, and therefore no window, when a result set is first created. The default position is before the first row, which is not a valid current row.
As you move from row to row, the window remains unchanged as long as the current row stays within that window. However, once you move to a new current row outside the window, you redefine the window to be the N rows starting with the new current row.
Whenever the window is redefined, the N rows in the database corresponding to the rows in the new window are automatically refetched through an implicit call to the refreshRow()
method (described in "Refetching Rows"), thereby updating the data throughout the new window.
So external updates are not instantaneously visible in a scroll-sensitive result set; they are only visible after the automatic refetches just described.
For a sample application that demonstrates the functionality of a scroll-sensitive result set, see "Scroll-Sensitive Result Set--ResultSet5.java".
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|