Ref Cursor Support v13
The Advanced Server Open Client Library supports the use of REF CURSOR
as OUT
parameters in PL/SQL procedures that are compatible with Oracle. Support is provided through the following APIs:
OCIBindByName
OCIBindByPos
OCIBindDynamic
OCIStmtPrepare
OCIStmtExecute
OCIStmtFetch
OCIAttrGet
The EDB OCL connector also supports the SQLT_RSET
data type.
The following example demonstrates how to invoke a stored procedure that opens a cursor and returns a REF CURSOR
as an output parameter. The code sample assumes that a PL/SQL procedure named openCursor
(with an OUT
parameter of type REF CURSOR
) has been created on the database server, and that the required handles have been allocated:
Allocate handles for executing a stored procedure to open and use the REF CURSOR
:
Then, prepare the PL/SQL block that is used to open the REF CURSOR
:
Bind the PL/SQL openCursor OUT
parameter:
Use the stmtOpenRefCursor
statement handle to call the openCursor
procedure:
At this point, the stmtUseRefCursor
statement handle contains the reference to the cursor. To obtain the information, define output variables for the ref cursor:
Then, fetch the first row of the result set into the target variables: