To issue an SQL statement in a CLI application,
you need to allocate a statement handle. A statement handle tracks
the execution of a single SQL statement and is associated with a connection
handle. Allocating statement handles is part of the larger task of
processing transactions.
Before you begin
Before you begin allocating statement handles, you must allocate
an environment handle and a connection handle. This is part of the
task of initializing your CLI application.
Procedure
To allocate a statement handle:
- Call
SQLAllocHandle() with
a HandleType of SQL_HANDLE_STMT. For
example:
SQLAllocHandle (SQL_HANDLE_STMT, hdbc, &hstmt);
- Optional: To set attributes for this statement,
call
SQLSetStmtAttr() for
each required attribute option.
Results
After allocating environment, connection, and statement handles,
you can now prepare, issue, or execute SQL statements.