Is the data fetched by an explicit cursor immutable in PL/SQL

cursorsoracleplsql

This seems like an obvious question, but Googling has so far failed me…

Say I have a view which delineates updates that I need to apply and, to this end, I have an SP that opens the view as a cursor, iterates through each row and makes the appropriate change. The thing is, the updates made by the SP will alter the contents of the view (e.g., once the inconsistency has been dealt with, the row will disappear from the view).

Will this be reflected in the open cursor (in the SP), or is the data that it fetches fixed when it is first opened?

What I've read suggests that the cursor data is immutable once it's been opened — which is good — however, I've yet to find a straight answer.

Best Answer

Oracle will provide a read-consistent view of the data. Assuming that you're using the default transaction isolation level of read committed, the data that a query will return is fixed at the point in time that the cursor is opened (whether the cursor is implicit or explicit is irrelevant).

The only exception to this is that PL/SQL that is called by the query (i.e. stored functions) will see the data as it exists at the point in time that the function is called not at the point that the cursor was opened.