SQLFreeEnv - Free environment handle

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

SQLFreeConnect() must be called before calling this function.

This function is the last DB2 for i CLI step that an application needs before it ends.

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

  • SQL_SUCCESS
  • SQL_ERROR
  • SQL_INVALID_HANDLE

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