Declaring a cursor variable v14
SPL supports two ways of declaring a cursor variable:
- Using the
SYS_REFCURSOR
built-in data type.SYS_REFCURSOR
is aREF CURSOR
type that allows any result set to be associated with it. This is known as a weakly-typedREF CURSOR
. - Creating a type of
REF CURSOR
and then declaring a variable of that type.
Only the declaration of SYS_REFCURSOR
and user-defined REF CURSOR
variables differ. The remaining usage, such as opening the cursor, selecting into the cursor, and closing the cursor, is the same for both the cursor types. The examples primarily make use of the SYS_REFCURSOR
cursors. To make the examples work for a user-defined REF CURSOR
, change the declaration section.
Note
A strongly-typed REF CURSOR
requires the result set to conform to a declared number and order of fields with compatible data types. It can also optionally return a result set.
declaring_a_sys_refcursor_cursor_variable declaring_a_user_defined_ref_cursor_type_variable