7.1 Connector/ODBC API Reference

This section summarizes ODBC routines, categorized by functionality.

For the complete ODBC API reference, please refer to the ODBC Programmer's Reference at http://msdn.microsoft.com/en-us/library/ms714177.aspx.

An application can call SQLGetInfo function to obtain conformance information about Connector/ODBC. To obtain information about support for a specific function in the driver, an application can call SQLGetFunctions.

Note

For backward compatibility, the Connector/ODBC driver supports all deprecated functions.

The following tables list Connector/ODBC API calls grouped by task:

Table 7.1 ODBC API Calls for Connecting to a Data Source

Function NameConnector/ODBC Supports?StandardPurpose
SQLAllocHandleYesISO 92Obtains an environment, connection, statement, or descriptor handle.
SQLConnectYesISO 92Connects to a specific driver by data source name, user ID, and password.
SQLDriverConnectYesODBCConnects to a specific driver by connection string or requests that the Driver Manager and driver display connection dialog boxes for the user.
SQLAllocEnvYesDeprecatedObtains an environment handle allocated from driver.
SQLAllocConnectYesDeprecatedObtains a connection handle

Table 7.2 ODBC API Calls for Obtaining Information about a Driver and Data Source

Function NameConnector/ODBC Supports?StandardPurpose
SQLDataSourcesNoISO 92Returns the list of available data sources, handled by the Driver Manager
SQLDriversNoODBCReturns the list of installed drivers and their attributes, handles by Driver Manager
SQLGetInfoYesISO 92Returns information about a specific driver and data source.
SQLGetFunctionsYesISO 92Returns supported driver functions.
SQLGetTypeInfoYesISO 92Returns information about supported data types.

Table 7.3 ODBC API Calls for Setting and Retrieving Driver Attributes

Function NameConnector/ODBC Supports?StandardPurpose
SQLSetConnectAttrYesISO 92Sets a connection attribute.
SQLGetConnectAttrYesISO 92Returns the value of a connection attribute.
SQLSetConnectOptionYesDeprecatedSets a connection option
SQLGetConnectOptionYesDeprecatedReturns the value of a connection option
SQLSetEnvAttrYesISO 92Sets an environment attribute.
SQLGetEnvAttrYesISO 92Returns the value of an environment attribute.
SQLSetStmtAttrYesISO 92Sets a statement attribute.
SQLGetStmtAttrYesISO 92Returns the value of a statement attribute.
SQLSetStmtOptionYesDeprecatedSets a statement option
SQLGetStmtOptionYesDeprecatedReturns the value of a statement option

Table 7.4 ODBC API Calls for Preparing SQL Requests

Function NameConnector/ODBC Supports?StandardPurpose
SQLAllocStmtYesDeprecatedAllocates a statement handle
SQLPrepareYesISO 92Prepares an SQL statement for later execution.
SQLBindParameterYesODBCAssigns storage for a parameter in an SQL statement. Connector/ODBC 5.2 adds support for out and inout parameters, through the SQL_PARAM_OUTPUT or SQL_PARAM_INPUT_OUTPUT type specifiers. (Out and inout parameters are not supported for LONGTEXT and LONGBLOB columns.)
SQLGetCursorNameYesISO 92Returns the cursor name associated with a statement handle.
SQLSetCursorNameYesISO 92Specifies a cursor name.
SQLSetScrollOptionsYesODBCSets options that control cursor behavior.

Table 7.5 ODBC API Calls for Submitting Requests

Function NameConnector/ODBC Supports?StandardPurpose
SQLExecuteYesISO 92Executes a prepared statement.
SQLExecDirectYesISO 92Executes a statement
SQLNativeSqlYesODBCReturns the text of an SQL statement as translated by the driver.
SQLDescribeParamYesODBCReturns the description for a specific parameter in a statement.
SQLNumParamsYesISO 92Returns the number of parameters in a statement.
SQLParamDataYesISO 92Used in conjunction with SQLPutData to supply parameter data at execution time. (Useful for long data values.)
SQLPutDataYesISO 92Sends part or all of a data value for a parameter. (Useful for long data values.)

Table 7.6 ODBC API Calls for Retrieving Results and Information about Results

Function NameConnector/ODBC Supports?StandardPurpose
SQLRowCountYesISO 92Returns the number of rows affected by an insert, update, or delete request.
SQLNumResultColsYesISO 92Returns the number of columns in the result set.
SQLDescribeColYesISO 92Describes a column in the result set.
SQLColAttributeYesISO 92Describes attributes of a column in the result set.
SQLColAttributesYesDeprecatedDescribes attributes of a column in the result set.
SQLFetchYesISO 92Returns multiple result rows.
SQLFetchScrollYesISO 92Returns scrollable result rows.
SQLExtendedFetchYesDeprecatedReturns scrollable result rows.
SQLSetPosYesODBCPositions a cursor within a fetched block of data and enables an application to refresh data in the rowset or to update or delete data in the result set.
SQLBulkOperationsYesODBCPerforms bulk insertions and bulk bookmark operations, including update, delete, and fetch by bookmark.

Table 7.7 ODBC API Calls for Retrieving Error or Diagnostic Information

Function NameConnector/ODBC Supports?StandardPurpose
SQLErrorYesDeprecatedReturns additional error or status information
SQLGetDiagFieldYesISO 92Returns additional diagnostic information (a single field of the diagnostic data structure).
SQLGetDiagRecYesISO 92Returns additional diagnostic information (multiple fields of the diagnostic data structure).

Table 7.8 ODBC API Calls for Obtaining Information about the Data Source's System Tables (Catalog Functions) Item

Function NameConnector/ODBC Supports?StandardPurpose
SQLColumnPrivilegesYesODBCReturns a list of columns and associated privileges for one or more tables.
SQLColumnsYesX/OpenReturns the list of column names in specified tables.
SQLForeignKeysYesODBCReturns a list of column names that make up foreign keys, if they exist for a specified table.
SQLPrimaryKeysYesODBCReturns the list of column names that make up the primary key for a table.
SQLSpecialColumnsYesX/OpenReturns information about the optimal set of columns that uniquely identifies a row in a specified table, or the columns that are automatically updated when any value in the row is updated by a transaction.
SQLStatisticsYesISO 92Returns statistics about a single table and the list of indexes associated with the table.
SQLTablePrivilegesYesODBCReturns a list of tables and the privileges associated with each table.
SQLTablesYesX/OpenReturns the list of table names stored in a specific data source.

Table 7.9 ODBC API Calls for Performing Transactions

Function NameConnector/ODBC Supports?StandardPurpose
SQLTransactYesDeprecatedCommits or rolls back a transaction
SQLEndTranYesISO 92Commits or rolls back a transaction.

Table 7.10 ODBC API Calls for Terminating a Statement

Function NameConnector/ODBC Supports?StandardPurpose
SQLFreeStmtYesISO 92Ends statement processing, discards pending results, and, optionally, frees all resources associated with the statement handle.
SQLCloseCursorYesISO 92Closes a cursor that has been opened on a statement handle.
SQLCancelYesISO 92Cancels an SQL statement.

Table 7.11 ODBC API Calls for Terminating a Connection

Function NameConnector/ODBC Supports?StandardPurpose
SQLDisconnectYesISO 92Closes the connection.
SQLFreeHandleYesISO 92Releases an environment, connection, statement, or descriptor handle.
SQLFreeConnectYesDeprecatedReleases connection handle.
SQLFreeEnvYesDeprecatedReleases an environment handle.