Choosing cursor characteristics

ODBC functions that execute statements and manipulate result sets use cursors to carry out their tasks. Applications open a cursor implicitly when they execute a statement that returns a result set.

For applications that move through a result set only in a forward direction and do not update the result set, cursor behavior is relatively straightforward. By default, ODBC applications request this behavior. ODBC defines a read-only, forward-only cursor, and the ASE ODBC Driver provides a cursor optimized for performance in this case.

To set the required ODBC cursor characteristics, call the SQLSetStmtAttr function that defines statement attributes. You must call SQLSetStmtAttr before executing a statement that returns a result set.

You can use SQLSetStmtAttr to set many cursor characteristics. The characteristic that determines the cursor type for the ASE ODBC Driver is SQL_ATTR_CONCURRENCY. You can set one of the following values:

For more information, see SQLSetStmtAttr in the Microsoft ODBC Programmer's Reference.

Example

The following fragment requests an updateable cursor:

SQLAllocHandle( SQL_HANDLE_STMT, dbc, &stmt );
SQLSetStmtAttr( stmt, SQL_ATTR_CONCURRENCY,
   SQL_CONCUR_LOCK, 0 );

NoteBefore using cursors, verify that UseCursor property is set to 1. The default value for UseCursor is 0.