SQLFreeEnv - Free environment handle

Purpose

SQLFreeEnv() invalidates and frees the environment handle. All DB2® UDB CLI resources associated with the environment handle are freed.

SQLFreeConnect() must be called before calling this function.

This function is the last DB2 UDB CLI step an application needs before terminating.

Syntax

SQLRETURN SQLFreeEnv (SQLHENV    henv);

Function arguments

Table 1. SQLFreeEnv arguments
Data type Argument Use Description
SQLHENV henv Input Environment handle

Usage

If this function is called when there is still a valid connection handle, SQL_ERROR is returned, and the environment handle remains valid.

Return codes

Diagnostics

Table 2. SQLFreeEnv SQLSTATEs
SQLSTATE Description Explanation
58004 System error Unrecoverable system error.
HY001 Memory allocation failure The driver is unable to allocate memory required to support the processing or completion of the function.
HY010 Function sequence error There is an hdbc which is in allocated or connected state. Call SQLDisconnect and SQLFreeConnect for the hdbc before calling SQLFreeEnv.
HY013 * Memory management problem The driver is unable to access memory required to support the processing or completion of the function.

Example

Refer to the example in SQLAllocEnv().

References

SQLFreeConnect - Free connection handle