ODBC functions

Db2 ODBC provides various SQL-related functions with unique purposes, diagnostics, and restrictions.

About these topics

These topics might contain any of the following sections, in addition to other sections. Certain sections are omitted for deprecated functions.

Purpose
Contains a table that indicates the specifications and standards to which the function conforms.

The first column indicates whether the function is included in the ODBC specification and identifies the first ODBC version (1.0, 2.0, or 3.0) that includes the specification for the function. The second column indicates whether the function is included in the X/Open CLI CAE specification, and the third column indicates if the function is included in the ISO CLI standard. The following table is an example of the specifications table for an ODBC 3.0 function that is included in both the X/Open CLI CAE specification and the ISO CLI standard.

Table 1. Sample function specification table
ODBC X/OPEN CLI ISO CLI
3.0 Yes Yes
Syntax
Contains a generic C language prototype for the function.

All function arguments that are pointers are defined using the FAR macro. This macro is defined out (set to a blank). This is consistent with the ODBC specification.

Function arguments
Lists each function argument, along with its data type, a description and a indication of whether it is an input or output argument.

Only SQLGetInfo() and SQLBindParameter() use parameters for both input and output.

Some functions use input or output arguments that are known as deferred or bound arguments. These arguments are pointers to buffers that you allocate in your application and associate with (or bind to) either a parameter in an SQL statement or a column in a result set. Db2 ODBC accesses these buffers when you execute the SQL statement or retrieve the result set to which the deferred arguments are bound.

Important: For input arguments, ensure that deferred data areas contain valid data when you execute a statement that requires these values. For output arguments, ensure that deferred data areas remain allocated until you finish retrieving results.
Return codes
Lists all the possible function return codes. When SQL_ERROR or SQL_SUCCESS_WITH_INFO is returned, you can obtain error information by calling SQLGetDiagRec()
Diagnostics
Contains SQLSTATEs that are explicitly returned by Db2 ODBC and indicates the cause of the error. (Db2 ODBC can also return SQLSTATEs that the database management system generates.) To obtain these SQLSTATE values, call SQLGetDiagRec() on a function that returns SQL_ERROR or SQL_SUCCESS_WITH_INFO.