ODBC API

Connecting to Data Sources

SQLAllocEnv

SQLAllocConnect

SQLConnect

SQLDriverConnect
(Level 1 Extension)

SQLBrowseConnect
(Level 2 Extension)

Disconnecting from a Data Source

SQLDisconnect

SQLFreeConnect

SQLFreeEnv

Setting & Retrieving Connection Options

SQLSetConnectOption
(Level 1 Extension)

SQLGetConnectOption
(Level 1 Extension)

SQLSetStmtOption
(Level 1 Extension)

SQLGetStmtOption
(Level 1 Extension)

Obtaining Information about a Driver or Data Source

SQLGetFunctions
(Level 1 Extension)

SQLGetTypeInfo
(Level 1 Extension)

SQLGetInfo
(Level 1 Extension)

SQLDataSources
(Level 2 Extension)

SQLDrivers
(Level 2 Extension)

Preparing SQL Requests to be Executed Multiple Times

SQLAllocStmt

SQLPrepare

SQLBindParameter
(Level 1 Extension)

SQLParamOptions
(Level 2 Extension)

SQLGetCursorName

SQLSetCursorName

SQLSetScrollOptions
(Level 2 Extension)

Submitting SQL Requests

SQLExecute

SQLExecDirect

SQLNativeSQL
(Level 2 Extension)

SQLDescribeParam
(Level 2 Extension)

SQLNumParams
(Level 2 Extension)

SQLParamData
(Level 1 Extension)

SQLPutData
(Level 1 Extension)

Retrieving Results and Information about Results

SQLRowCount

SQLNumResultCols

SQLDescribeCol

SQLColAttributes

SQLBindCol

SQLFetch

SQLExtendedFetch
(Level 2 Extension)

SQLGetData
(Level 1 Extension)

SQLSetPos
(Level 2 Extension)

SQLMoreResults
(Level 2 Extension)

SQLError

Terminating a Statement

SQLFreeStmt

SQLCancel

SQLTransact

Obtaining information about the Data Source's system tables (catalog functions)

SQLColumnPrivileges
(Level 2 Extension)

SQLColumns
(Level 1 Extension)

SQLForeignKeys
(Level 2 Extension)

SQLPrimaryKeys
(Level 2 Extension)

SQLProcedureColumns
(Level 2 Extension)

SQLProcedures
(Level 2 Extension)

SQLSpecialColumns
(Level 1 Extension)

SQLStatistics
(Level 1 Extension)

SQLTablePrivileges
(Level 2 Extension)

SQLTables
(Level 1 Extension)

ODBC C API DEFINITION: SQLGetFunctions


Extension Level 1

SQLGetFunctions returns information about whether a driver supports a specific ODBC function. This function is implemented in the Driver Manager; it can also be implemented in drivers. If a driver implements SQLGetFunctions, the Driver Manager calls the function in the driver. Otherwise, it executes the function itself.

SyntaxRETCODE SQLGetFunctions(hdbc, fFunction, pfExists)

The SQLGetFunctions function accepts the following arguments.

Type

Argument

Use

Description

HENVhdbcInputConnection handle.
UWORDfFunctionInputSQL_API_ALL_FUNCTIONS or a #define value that identifies the ODBC function of interest. For a list of #define values that identify ODBC functions, see the tables in "Comments".
UWORD FAR *pfExistsOutputIf fFunction is SQL_API_ALL_FUNCTIONS, pfExists points to a UWORD array with 100 elements. The array is indexed by #define values used by fFunction to identify each ODBC function; some elements of the array are unused and reserved for future use. An element is TRUE if it identifies an ODBC function supported by the driver. It is FALSE if it identifies an ODBC function not supported by the driver or does not identify an ODBC function.

Note The fFunction value SQL_API_ALL_FUNCTIONS was added in ODBC 2.0.


If fFunction identifies a single ODBC function, pfExists points to single UWORD. pfExists is TRUE if the specified function is supported by the driver; otherwise, it is FALSE.
ReturnsSQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR or SQL_INVALID_HANDLE

If SQLAllocConnect returns SQL_ERROR, it will set the hdbc referenced by phdbc to SQL_NULL_HDBC. To obtain additional information, the application can call SQLError with the specified henv and with hdbc and hstmt set to SQL_NULL_HDBC and SQL_NULL_HSTMT, respectively.

Diagnostics

When SQLGetFunctions returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value may be obtained by calling SQLError. The following table lists the SQLSTATE values commonly returned by SQLGetFunctions and explains each one in the context of this function; the notation "(DM)" precedes the descriptions of SQLSTATEs returned by the Driver Manager. The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.

SQLSTATE

Error

Description

01000General warningDriver-specific informational message. (Function returns SQL_SUCCESS_WITH_INFO.)
S1000General errorAn error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by SQLError in the argument szErrorMsg describes the error and its cause.
S1001Memory allocation failure(DM) The Driver Manager was unable to allocate memory for the connection handle. The driver was unable to allocate memory for the connection handle.
S1010Function sequence error(DM) SQLGetFunctions was called before SQLConnect, SQLBrowseConnect or SQLDriverConnect.
(DM) SQLBrowseConnect was called for the hdbc and returned SQL_NEED_DATA. This function was then called before SQLBrowseConnect returned SQL_SUCCESS_WITH_INFO or SQL_SUCCESS.
S1095Function type out of range(DM) An invalid fFunction value was specified.
Comments

SQLGetFunctions always returns that SQLGetFunctions, SQLDataSources and SQLDrivers are supported. It does this because these functions are implemented in the Driver Manager.

The following table lists valid values for fFunction for ODBC core functions.

SQL_API_SQLALLOCCONNECTSQL_API_SQLFETCH
SQL_API_SQLALLOCENVSQL_API_SQLFREECONNECT
SQL_API_SQLALLOCSTMTSQL_API_SQLFREEENV
SQL_API_SQLBINDCOLSQL_API_SQLFREESTMT
SQL_API_SQLCANCELSQL_API_SQLGETCURSORNAME
SQL_API_SQLCOLATTRIBUTESSQL_API_SQLNUMRESULTCOLS
SQL_API_SQLCONNECTSQL_API_SQLPREPARE
SQL_API_SQLDESCRIBECOLSQL_API_SQLROWCOUNT
SQL_API_SQLDISCONNECTSQL_API_SQLSETCURSORNAME
SQL_API_SQLERRORSQL_API_SQLSETPARAM
SQL_API_SQLEXECDIRECTSQL_API_SQLSETPARAM
SQL_API_SQLEXECUTE

Note For ODBC 1.0 drivers, SQLGetFunctions returns TRUE in pfExists if fFunction is SQL_API_SQLBINDPARAMETER or SQL_API_SQLSETPARAM and the driver supports SQLSetParam. For ODBC 2.0 drivers, SQLGetFunctions returns TRUE in pfExists if fFunction is SQL_API_SQLSETPARAM or SQL_API_SQLBINDPARAMETER and the driver supports SQLBindParameter.


The following table lists valid values for fFunction for ODBC extension level 1 functions.

SQL_API_SQLBINDPARAMETERSQL_API_SQLGETTYPEINFO
SQL_API_SQLCOLUMNSSQL_API_SQLPARAMDATA
SQL_API_SQLDRIVERCONNECTSQL_API_SQLPUTDATA
SQL_API_SQLGETCONNECTOPTIONSQL_API_SQLSETCONNECTOPTION
SQL_API_SQLGETDATASQL_API_SQLSETSTMTOPTION
SQL_API_SQLGETFUNCTIONSSQL_API_SQLSPECIALCOLUMNS
SQL_API_SQLGETINFOSQL_API_SQLSTATISTICS
SQL_API_SQLGETSTMTOPTIONSQL_API_SQLTABLES

The following table lists valid values for fFunction for ODBC extension level 2 functions.

SQL_API_SQLBROWSECONNECTSQL_API_SQLNUMPARAMS
SQL_API_SQLCOLUMNPRIVILEGESSQL_API_SQLPARAMOPTIONS
SQL_API_SQLDATASOURCESSQL_API_SQLPRIMARYKEYS
SQL_API_SQLDESCRIBEPARAMSQL_API_SQLPROCEDURECOLUMNS
SQL_API_SQLDRIVERSSQL_API_SQLPROCEDURES
SQL_API_SQLEXTENDEDFETCHSQL_API_SQLSETPOS
SQL_API_SQLFOREIGNKEYSSQL_API_SQLSETSCROLLOPTIONS
SQL_API_SQLMORERESULTSSQL_API_SQLSETSCROLLOPTIONS
SQL_API_SQLNATIVESQL
Code Example(future)
Related Functions
For information about

See

Returning the setting of a connection optionSQLGetConnectOption (extension)
Returning information about a driver or data sourceSQLGetInfo (extension)
Returning the setting of a statement optionSQLGetStmtOption (extension)

ODBC Router

ODBC Router transparently makes all ODBC drivers on a central Windows Server useable by your network's iPhone/iPod, iPad, Linux, Mac and Windows systems. Years in the making here in the USA, ODBC Router has saved its customers millions of dollars in DLL installations and support costs for less than the price of a new PC and a few minutes installation time. ODBC Router provides a low cost, turnkey database network with enterprise class IT support.

Ditching the ODBC Administrator Control Panel:

By linking your application with the free ODBC Router client-side SDK instead of the ODBC Driver Manager, the need for your end-users to deal with driver installation or an ODBC Control Panel is gone! We even provide a setup function your code may call to display a "network browser" that enables your customer to "find" their ODBC Router server on the network, then "choose" the exact database they want to work with and finally return to your application with a fully-formed ODBC connection-string that may be stored and passed back to SQLConnect or SQLDriverConnect anytime your user wants to initiate a connection that data source. No more walking your customers through the process of adding data sources to ODBC Control Panel or, in the case of non-Windows computers, no need to worry about whether or not a compatible third-party ODBC Driver Manager has been installed for use with your code. (Remember that ODBC Router supports iPhone/iPod, iPad, Mac OS 9, Mac OS X, Linux and Windows.) If there ever are any client-side ODBC support issues, AugSoft can handle them directly with the customer freeing you to focus on the application.

JDBC?

JDBC-in-ODBC drivers (like some 'actual' ODBC drivers, lol) launch a CPU-intensive virtual machine in the background on your machine, which is bad for battery powered laptops, high-volume web servers or entry level desktops (that typically have slow busses and drives). As the world shifted to laptops and shared servers, the whole "virtual machine" concept became a support nightmare and so these days good Java apps are compiled to run as native (not emulated) code. Java developers may use the operating system's native ODBC support from within the JDBC class library using the sun.jdbc.odbc.JdbcOdbcDriver driver with a URL as shown below.

jdbc:odbc:dsn[;key=value]*

Example:

jdbc:odbc:finance;UID=cfo;

IT techs may then complete the database connection on the Customer's machine using ODBC Router or the database vendor's official ODBC driver.

NOTE: By creating ODBC data sources with ODBC Router, your apps will enjoy native speed and database independent connections from either Java/C/C++/C#/ObjC or PHP/PERL/Python/Ruby/BASIC on Linux, Macintosh and Windows. Also be aware that using ODBC Router with the Mac platform is an especially good idea because database vendors have not kept their Mac drivers in sync with Windows and there are actual third-party vendors who wrap freeware and JDBC drivers inside of ODBC "shells" without warning their customers! This problem is of great concern to developers because fake drivers almost always fly past the IT guys who test with speed deamon desktops, but fail the enterprise when user laptops and iMacs take too long to run queries or slowly corrupt the database when they do. IT guys often chalk this up to "network problems" leaving users with poison drivers to avoid their database. ODBC Router addresses this issue by enabling official vendor supported Windows ODBC drivers (on a Windows Server) to be accessed from all platforms, network wide.

ODBC 3.x?

It's not here yet. Even in 2010, most ODBC drivers are ODBC 1.x and 2.x. The ODBC Driver Manager translates between 3.x and 2.x or 2.x and 1.x ODBC calls. Therefore, if you don't need UNICODE, it's a bad idea to use ODBC 3.x API calls. That said, UNICODE is a Good Thing and there are actually at least three databases that natively support it now, so look for 3.x to be here soon.

Need ODBC API Help?

We really know ODBC and we routinely provide code-level ODBC help to our customers. Our low cost ODBC Router systems are available now at our online store and if your site buys them, you may open a ticket to ask ODBC development questions --we offer both E-Mail and On-Call support options in seven of the G8's timezones! Be sure to test your ODBC Router and ask for any needed installation help before purchase because we aren't Fry's --no refunds please, our prices are too low for such nonsense and we're too busy supporting real Customers!

© Copyright 1990-2010, August Software, USA. All Rights Reserved.