Select Cursor or Function Cursor
- If you associate a SELECT statement with a cursor, the cursor
is called a Select cursor.
A Select cursor is a data structure that represents a specific location within the active set of rows that the SELECT statement retrieved.
- If you associate an EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement
with a cursor, the cursor is called a Function cursor.
The Function cursor represents the columns or values that a user-defined function returns. Function cursors behave the same as Select cursors that are enabled as update cursors.
In HCL OneDB™, for compatibility with legacy applications, if an SPL function was created with the CREATE PROCEDURE statement, you can create a Function cursor with the EXECUTE PROCEDURE statement. With external functions, you must use the EXECUTE FUNCTION statement.
When you associate a SELECT or EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement with a cursor, the statement can include an INTO clause. However, if you prepare the SELECT or EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement, you must omit the INTO clause in the PREPARE statement and use the INTO clause of the FETCH statement to retrieve the values from the Collection cursor.
- DECLARE
Use DECLARE to define a cursor and associate it with a statement.
- OPEN
Use OPEN to open the cursor. The database server processes the query until it locates or constructs the first row of the active set.
- FETCH
Use FETCH to retrieve successive rows of data from the cursor.
- CLOSE
Use CLOSE to close the cursor when its active set is no longer needed.
- FREE
Use FREE to release the resources that are allocated for the cursor.