Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 1.52 KB

allocating-a-statement-handle-odbc.md

File metadata and controls

33 lines (26 loc) · 1.52 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords
Allocating a Statement Handle ODBC
Allocating a Statement Handle ODBC
David-Engel
davidengel
01/19/2017
sql
connectivity
conceptual
SQL statements [ODBC], statement handles
statement handles [ODBC]
allocating statement handles [ODBC]
handles [ODBC], statement

Allocating a Statement Handle ODBC

Before the application can execute a statement, it must allocate a statement handle as follows:

  1. The application declares a variable of type HSTMT. It then calls SQLAllocHandle and passes the address of this variable, the handle of the connection in which to allocate the statement, and the SQL_HANDLE_STMT option. For example:

    SQLHSTMT hstmt1;  
    
    SQLAllocHandle(SQL_HANDLE_STMT, hdbc1, &hstmt1);  
    
  2. The Driver Manager allocates a structure in which to store information about the statement and calls SQLAllocHandle in the driver with the SQL_HANDLE_STMT option.

  3. The driver allocates its own structure in which to store information about the statement and returns the driver statement handle to the Driver Manager.

  4. The Driver Manager returns the Driver Manager statement handle to the application in the application variable.

The statement handle identifies which statement to use when calling ODBC functions. For more information about statement handles, see Statement Handles.