MDAC 2.5 SDK - ODBC Programmer's Reference
Chapter 9: Executing Statements
Direct execution is the simplest way to execute a statement. When the statement is submitted for execution, the data source compiles it into an access plan and then executes that access plan.
Direct execution is commonly used by generic applications that build and execute statements at run time. For example, the following code builds an SQL statement and executes it a single time:
SQLCHAR *SQLStatement;
// Build an SQL statement.
BuildStatement(SQLStatement);
// Execute the statement.
SQLExecDirect(hstmt, SQLStatement, SQL_NTS);
Direct execution works best for statements that will be executed a single time. Its major drawback is that the SQL statement is parsed every time it is executed. In addition, the application cannot retrieve information about the result set created by the statement (if any) until after the statement is executed; this is possible if the statement is prepared and executed in two separate steps.
To execute a statement directly, the application performs the following actions: