Fetching rows from a cursor v15
Once a cursor is open, you can retrieve rows from the cursor’s result set by using the
name is the identifier of a previously opened cursor.
record is the identifier of a previously defined record (for example, using
variable, variable_2... are SPL variables that receive the field data from the fetched row. The fields in
variable, variable_2... must match in number and order the fields returned in the
SELECT list of the query given in the cursor declaration. The data types of the fields in the
SELECT list must match or be implicitly convertible to the data types of the fields in
record or the data types of
A variation of
FETCH INTO using the
BULK COLLECT clause can return multiple rows at a time into a collection. See Using the BULK COLLECT clause for more information on using the
BULK COLLECT clause with the
FETCH INTO statement.
The following shows the
Instead of explicitly declaring the data type of a target variable, you can use
%TYPE instead. In this way, if the data type of the database column changes, the target variable declaration in the SPL program doesn't have to change.
%TYPE picks up the new data type of the specified column.
If all the columns in a table are retrieved in the order defined in the table, you can use
%ROWTYPE to define a record into which the
FETCH statement places the retrieved data. You can then access each field in the record using dot notation: