Edit

Share via


ODBC functions and the cursor library

Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance

Important

This feature will be removed in a future version of Windows. Avoid using this feature in new development work and plan to modify applications that currently use this feature. Microsoft recommends using the driver's cursor functionality.

The ODBC cursor library provides scrollable cursor support for ODBC 2.x drivers that support only forward-only cursors. When you enable the cursor library for a connection, the Driver Manager intercepts function calls and routes them through the cursor library instead of directly to the driver. The cursor library either executes the function itself or passes it to the underlying driver.

Functions executed by the cursor library

These articles describe which ODBC functions the cursor library handles and which it passes through to the driver.

Article Description
ODBC functions executed by the cursor library Lists functions that the cursor library implements itself to provide scrollable cursor functionality.
ODBC functions not executed by the cursor library Lists functions that the cursor library passes through to the driver without modification.

Column and parameter binding

These functions handle binding application buffers to result set columns and statement parameters. The cursor library modifies their behavior to support positioned updates and block cursors.

Function Description
SQLBindCol (Cursor Library) Binds application buffers to result set columns. The cursor library tracks bindings to support positioned update and delete operations.
SQLBindParameter (Cursor Library) Binds application buffers to parameter markers. The cursor library passes this call to the driver.

Bulk and positioned operations

These functions perform bulk operations on rowsets and positioned updates on individual rows within a cursor's current rowset.

Function Description
SQLBulkOperations (Cursor Library) Performs bulk insert, update, delete, or fetch by bookmark operations. The cursor library maps this to SQLSetPos when working with ODBC 2.x drivers.
SQLSetPos (Cursor Library) Positions the cursor within a rowset and allows applications to refresh, update, or delete data in the rowset.

Cursor management and transactions

These functions manage cursor lifetime and transaction boundaries.

Function Description
SQLCloseCursor (Cursor Library) Closes a cursor on a statement and discards pending results.
SQLEndTran (Cursor Library) Commits or rolls back a transaction. The cursor library manages cursor state across transaction boundaries based on the SQL_CURSOR_COMMIT_BEHAVIOR and SQL_CURSOR_ROLLBACK_BEHAVIOR settings.
SQLFreeStmt (Cursor Library) Stops statement processing, closes any associated cursor, discards pending results, and optionally frees all resources associated with the statement handle.

Data retrieval

These functions fetch data from result sets. The cursor library provides scrollable cursor functionality for drivers that only support forward-only cursors.

Function Description
SQLFetch (Cursor Library) Fetches the next rowset of data from the result set. When working with ODBC 2.x drivers, the cursor library maps this to SQLExtendedFetch.
SQLFetchScroll (Cursor Library) Fetches the specified rowset of data from the result set and returns data for all bound columns. Supports various scroll directions including first, last, next, prior, absolute, and relative positioning.
SQLExtendedFetch (Cursor Library) Fetches the specified rowset from the result set. This function is deprecated in ODBC 3.x; use SQLFetchScroll instead.
SQLGetData (Cursor Library) Retrieves data for a single column in the result set after SQLFetch or SQLFetchScroll has been called.

Descriptor operations

These functions get and set descriptor field values. Descriptors define the attributes of parameters and result set columns.

Function Description
SQLGetDescField and SQLGetDescRec (Cursor Library) Retrieve individual field values or complete descriptor records. The cursor library handles these for its internal descriptors.
SQLSetDescField and SQLSetDescRec (Cursor Library) Set individual field values or complete descriptor records. The cursor library tracks changes to descriptor fields.

Driver capability queries

These functions return information about the driver and cursor library capabilities.

Function Description
SQLGetFunctions (Cursor Library) Returns information about which ODBC functions the driver supports. The cursor library modifies the response to include functions it implements.
SQLGetInfo (Cursor Library) Returns general information about the driver and data source. The cursor library modifies certain cursor-related information types to reflect its capabilities.

Statement and connection attributes

These functions get and set statement, connection, and environment attributes that affect cursor behavior.

Function Description
SQLGetStmtAttr (Cursor Library) Returns the current value of a statement attribute. The cursor library handles attributes related to cursor behavior.
SQLGetStmtOption (Cursor Library) Returns statement option values. This function is deprecated in ODBC 3.x; use SQLGetStmtAttr instead.
SQLSetStmtAttr (Cursor Library) Sets a statement attribute. The cursor library processes cursor-related attributes to implement scrollable cursor support.
SQLSetScrollOptions (Cursor Library) Sets options that control cursor behavior. This function is deprecated in ODBC 3.x; use SQLSetStmtAttr with cursor-related attributes instead.
SQLSetConnectAttr (Cursor Library) Sets a connection attribute. The cursor library processes the SQL_ATTR_ODBC_CURSORS attribute to enable or disable cursor library use.
SQLSetEnvAttr (Cursor Library) Sets an environment attribute. The cursor library passes this call to the Driver Manager.

SQL translation and row operations

These functions handle SQL statement translation and row count retrieval.

Function Description
SQLNativeSql (Cursor Library) Returns the SQL string as modified by the driver. The cursor library passes this call to the driver without modification.
SQLRowCount (Cursor Library) Returns the number of rows affected by an UPDATE, INSERT, or DELETE statement. The cursor library tracks row counts for positioned update and delete operations.