oracle / oracle-r2dbc

R2DBC Driver for Oracle Database
https://oracle.com
Other
194 stars 40 forks source link

REF CURSOR Support #94

Closed Michael-A-McMahon closed 1 year ago

Michael-A-McMahon commented 1 year ago

This branch adds support for REF CURSOR results from PL/SQL. A new REF_CURSOR constant in OracleR2dbcTypes allows out parameters to be registered for this type. Readable.get(...) methods allow REF CURSOR values to be mapped to Result objects. The rows of a REF CURSOR may then be consumed by calling Result.map(*) methods or Result.flatMap(...).

Oracle R2DBC uses Oracle JDBC statements to execute PL/SQL. When Oracle R2DBC returns a Result that is backed by a JDBC ResultSet, the JDBC statement must be held open until that ResultSet is consumed (b/c closing a JDBC statement closes the ResultSet). A solution for this was present in the current code base, but the design was broken by REF CURSORS. The design assumed that, before any Result was emitted to user code, all ResultSets would could be accounted. With REF CURSORS, new ResultSets can be created after Results are emitted.

The new constraint is that Oracle R2DBC doesn't know how many ResultSets will exist until user code executes a row mapping function. To handle this case, a new DependentCounter object is added. This object allows the number of ResultSets that depend on the JDBC statement to increase after Results are emitted to user code.