Some ODBC drivers only support the default cursor settings; these drivers also do not support positioned cursor operations, such as SQLSetPos. The ODBC cursor library is a component of the ODBC SDK used to implement block or static cursors on a driver that normally does not support them. The cursor library also implements positioned UPDATE and DELETE statements and SQLSetPos for the cursors it creates.
The ODBC cursor library is implemented as a layer between the ODBC Driver Manager and an ODBC driver. If the ODBC cursor library is loaded, the ODBC Driver Manager routes all cursor-related commands to the cursor library instead of the driver. The cursor library implements a cursor by fetching the entire result set from the underlying driver and caching the result set on the client. When using the ODBC cursor library, the application is limited to the cursor functionality of the cursor library; any support for additional cursor functionality in the underlying driver is not available to the application.
There is little need for using the ODBC cursor library with the Microsoft® SQL Server™ ODBC driver because the driver itself supports more cursor functionality than the ODBC cursor library. The only reason to use the ODBC cursor library with the SQL Server ODBC driver is because the driver implements its cursor support through server cursors, and server cursors do not support all SQL statements. Anytime there is a need to have a static cursor with stored procedures, batches, or SQL statements containing COMPUTE, COMPUTE BY, FOR BROWSE, or INTO, consider using the ODBC cursor library. However, care must be used with the cursor library because it caches the entire result set on the client, which can use large amounts of memory and slow performance.
An application invokes the cursor library on a connection-by-connection basis by using SQLSetConnectAttr to set the SQL_ATTR_ODBC_CURSORS connection attribute before connecting to a data source. SQL_ATTR_ODBC_CURSORS is set to one of three values:
The cursor library (shipped with the SQL Server ODBC driver) allows applications to use multiple active statements on a connection, as well as scrollable, updatable cursors. The cursor library, Odbccr32.dll for ANSI applications and Odbccu32.dll for Unicode applications, must be loaded to support this functionality. Use SQLSetConnectAttr to specify how the cursor library should be used and SQLSetStmtAttr to specify the cursor type, concurrency, and rowset size.
SQLFetchScroll | SQLSetConnectAttr |
SQLSetStmtAttr | Client Cursors |