SQLReleaseEnv - Release all environment resources

Purpose

SQLReleaseEnv() 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 to do before terminating.

Syntax

SQLRETURN SQLReleaseEnv (SQLHENV    henv);

Function arguments

Table 1. SQLReleaseEnv 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. SQLReleaseEnv 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 SQLReleaseEnv.
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 the SQLAllocEnv - Allocate environment handle.

References