Version: 7.0.0

SQLAllocHandle ​

Function ​

Allocates an environment, connection, or statement handle, and can replace SQLAllocEnv, SQLAllocConnect, and SQLAllocStmt.

Prototype ​

c
SQLRETURN SQLAllocHandle(SQLSMALLINT   HandleType,    
                         SQLHANDLE     InputHandle,     
                         SQLHANDLE     *OutputHandlePtr);

Parameters ​

Table 1 SQLAllocHandle parameters

Keyword

Parameter Description

HandleType

Type of handles allocated by SQLAllocHandle. It must be one of the following values:

  • SQL_HANDLE_ENV (environment handle)
  • SQL_HANDLE_DBC (connection handle)
  • SQL_HANDLE_STMT (statement handle)

Handles must be allocated in the following order: first the environment handle, then the connection handle, and finally the statement handle. Each subsequently allocated handle depends on the handle allocated before it.

InputHandle

Type of the new handle to be allocated.

  • If HandleType is SQL_HANDLE_ENV, the value is SQL_NULL_HANDLE.
  • If HandleType is SQL_HANDLE_DBC, the value must be an environment handle.
  • If HandleType is SQL_HANDLE_STMT, the value must be a connection handle.

OutputHandlePtr

Output parameter: A pointer to a buffer in which the returned handle is stored in the newly allocated data structure.

Return Values ​

  • SQL_SUCCESS: The call is successful.

  • SQL_SUCCESS_WITH_INFO: Some warning information is present.

  • SQL_ERROR: The corresponding handle failed to be allocated.

  • SQL_INVALID_HANDLE: The input handle is invalid.

Example ​

See: Example