Call Level Interface Guide and Reference

SQLFreeEnv - Free Environment Handle

Status of this Function since DB2 CLI Version 5
Note:

In ODBC version 3, SQLFreeEnv() has been deprecated and replaced with SQLFreeHandle(); see SQLFreeHandle - Free Handle Resources for more information.

Although this version of DB2 CLI continues to support SQLFreeEnv(), we recommend that you begin using SQLFreeHandle() in your DB2 CLI programs so that they conform to the latest standards.

See DB2 CLI Functions Deprecated for Version 5 for more information on this and other deprecated functions.

Migrating to the New Function

The statement:

   SQLFreeEnv(henv);
for example, would be rewritten using the new function as:
   SQLFreeHandle(SQL_HANDLE_ENV, henv);

Purpose
Specification: DB2 CLI 1.1 ODBC 1.0 ISO CLI

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

SQLFreeConnect() must be called before calling this function.

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

Syntax

SQLRETURN   SQLFreeEnv       (SQLHENV           henv);

Function Arguments

Table 84. 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 will remain valid.

Return Codes

Diagnostics

Table 85. SQLFreeEnv SQLSTATEs
SQLSTATE Description Explanation
58004 Unexpected system failure. Unrecoverable system error.
HY001 Memory allocation failure. DB2 CLI is unable to allocate memory required to support execution 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 Unexpected memory handling error. DB2 CLI was unable to access memory required to support execution or completion of the function.

Authorization

None.

Example

Refer to SQLFreeHandle - Free Handle Resources.

References


[ Top of Page | Previous Page | Next Page ]