Direct Execution
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:
// Build an SQL statement.
BuildStatement(SQLStatement);
// Execute the statement.
SQLExecDirect(hstmt, SQLStatement, SQL_NTS);
To execute a statement directly, the application:
1 Sets the values of any parameters. For more information, see
2 Calls SQLExecDirect and passes it a string containing the SQL statement.
When SQLExecDirect is called, the driver:
1 Modifies the SQL statement to use the data source
2 Retrieves the current parameter values and converts them as necessary. For
more information, see
3 Sends the statement and converted parameter values to the data source for
execution.
4 Returns any errors. These include sequencing or state diagnostics such as
SQLSTATE 24000 (Invalid cursor state), syntactic errors such as SQLSTATE 42000
(Syntax error or access violation), and semantic errors such as SQLSTATE 42S02
(Base table or view not found).