ODBC APIs: General concepts

The following general concepts apply to IBM® i Access ODBC APIs.

Environments:
The environment in which Windows makes available some memory for ODBC to monitor its run-time information.
Connections:
Within the environment there can be multiple connections, each to a data source. The connections may be to different physical servers, to the same server, or any combination of both.
Statements:
Multiple statements can be run within each connection.
Handles:
Start of changeHandles are identifiers for storage areas that are allocated by the Driver Manager or individual drivers. The four types of handles are:
Environment handle:
Global information, that includes other handles. One handle is allowed per application.
Connection handle:
Information about connection to a data source. Multiple connection handles are allowed per environment.
Statement handle:
Information about a particular SQL statement. Multiple statement handles are allowed per connection. Statement handles can be reused for other SQL statements as long as the statement state is valid.
Descriptor handle:
Information about explicit descriptors that are associated with the connection handle. The application creates these, and asks the driver to use them instead of the implicit descriptors associated with a statement handle.

Start of changeEssentially, a handle can be considered as an identifier for a resource that is recognized by ODBC (an environment, connection, statement, or descriptor). ODBC provides an identifier (the handle) for this resource that you can use in your program. Exactly what ODBC stores in the handle (which is held as a long integer) is not relevant. Be careful not to change the value, and to assign unique names to the variables that hold the various handles.End of change

Some APIs set the handle (for example, SQLAllocEnv or SQLAllocHandle with SQL_HANDLE_ENV handle type), and you must pass in a reference, or pointer to the variable. Some APIs refer to a handle that previously was set (for example, SQLExecute), and you must pass in the variable by value.

End of change