To use cursors
Set the SQL_ATTR_CURSOR_TYPE and SQL_ATTR_CONCURRENCY attributes (this is the preferred option).
Or
Set the SQL_CURSOR_SCROLLABLE and SQL_CURSOR_SENSITIVITY attributes.
Or
Use row-wise binding.
If bound statement parameters are used for output parameters or the return value of a stored procedure, use the data now available in the bound parameter buffers.
When bound parameters are used, each call to SQLExecute or SQLExecDirect will have executed the SQL statement S times, where S is the number of elements in the array of bound parameters. This means that there will be S sets of results to process, where each set of results comprises all of the result sets, output parameters, and return codes usually returned by a single execution of the SQL statement.
Note that when a result set contains compute rows, each compute row is made available as a separate result set. These compute result sets are interspersed within the normal rows and break normal rows into multiple result sets.
In step 9, calling SQLMoreResults on a partially processed result set clears the remainder of the result set. Another way to clear a partially processed result set is to call SQLCloseCursor.
You can control the type of cursor used by either setting SQL_ATTR_CURSOR_TYPE and SQL_ATTR_CONCURRENCY, or by setting SQL_ATTR_CURSOR_SENSITIVITY and SQL_ATTR_CURSOR_SCROLLABLE. You should not mix the two methods of specifying cursor behavior, the Microsoft ODBC 3.0 Programmer’s Reference warns that this can prevent an ODBC driver from efficiently implementing the cursor.
How Cursors Are Implemented | SQLGetCursorName |
How to use rowset binding (ODBC) | SQLMoreResults |
Using Default Result Sets | SQLNumResultCols |
SQLFreeStmt | SQLSetStmtAttr |