SQLAllocHandle
Description
Allocates environment, connection, statement, or descriptor handles. This function replaces the deprecated ODBC 2.x functions SQLAllocEnv, SQLAllocConnect, and SQLAllocStmt.
Prototype
1 2 3 |
SQLRETURN SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandlePtr); |
Parameters
Keyword |
Description |
---|---|
HandleType |
Type of handle to be allocated by SQLAllocHandle. The value must be one of the following:
The handle application sequence is: environment handle > connection handle > statement handle. The handle applied later depends on the handle applied prior to it. |
InputHandle |
Existing handle to use as a context for the new handle being allocated.
|
OutputHandlePtr |
Output parameter: Pointer to a buffer that stores the returned handle in the newly allocated data structure. |
Return Value
- SQL_SUCCESS indicates that the call succeeded.
- SQL_SUCCESS_WITH_INFO indicates that some warning information is displayed.
- SQL_ERROR indicates major errors, such as memory allocation and connection failures.
- SQL_INVALID_HANDLE indicates that invalid handles were called. This value may also be returned by other APIs.
Precautions
If SQLAllocHandle returns SQL_ERROR when it is used to allocate a non-environment handle, it sets OutputHandlePtr to SQL_NULL_HDBC, SQL_NULL_HSTMT, or SQL_NULL_HDESC. The application can then call SQLGetDiagRec, with HandleType and Handle set to the value of IntputHandle, to obtain the SQLSTATE value. The SQLSTATE value provides the detailed function calling information.
Examples
See Examples.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot