SQLFreeHandle - Free a handle

SQLFreeHandle() invalidates and frees a handle.

Syntax

SQLRETURN SQLFreeHandle (SQLSMALLINT htype,
                        SQLINTEGER handle);

Function arguments

Table 1. SQLFreeHandle arguments
Data type Argument Use Description
SQLSMALLINT hType Input Handle type that must be SQL_HANDLE_ENV, SQL_HANDLE_DBC, SQL_HANDLE_STMT, or SQL_HANDLE_DESC.
SQLINTEGER handle Input The handle to be freed.

Usage

SQLFreeHandle() combines the function of SQLFreeEnv(), SQLFreeConnect(), and SQLFreeStmt().

Return codes

  • SQL_SUCCESS
  • SQL_ERROR
  • SQL_INVALID_HANDLE

Diagnostics

Table 2. SQLFreeHandle 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 SQLFreeHandle.
HY013 * Memory management problem The driver is unable to access memory required to support the processing or completion of the function.