There are three types of cursor-declare commands. Each one executes the cursor’s select statement differently:
The cursor executes a select statement directly.
The application calls ct_cursor and passes the select statement as the ct_cursor text argument.
The cursor executes a stored procedure.
The select statement is executed by a stored procedure that has been created ahead of time, either by the application itself or by the application administrator. To declare the cursor, call ct_cursor and pass, as the text argument, an execute statement that invokes the procedure. Cursors can be declared only on a stored procedure that contains a single select statement.
The cursor executes a prepared dynamic SQL statement.
The application calls ct_dynamic(CS_PREPARE) to create a prepared statement that executes the select statement. Then the application calls ct_dynamic(CS_CURSOR_DECLARE) and passes the statement identifier as the ct_dynamic id argument.