Step 3: Build and Execute an SQL Statement
If the SQL statement contains parameters, the application binds them to
application variables by calling SQLBindParameter for each parameter. For more information, see “Statement Parameters” in Chapter 9, “Executing Statements.”
After the SQL statement is built and any parameters are bound, the statement
is executed with SQLExecDirect. If the statement will be executed multiple times, it can be prepared with SQLPrepare and executed with SQLExecute. For more information, see “Executing a Statement” in Chapter 9, “Executing Statements.”
The application might also forgo executing an SQL statement altogether and
instead call a function to return a result set containing catalog information,
such as the available columns or tables. For more information, see “Uses of Catalog Data” in Chapter 7, “Catalog Functions.”
What the application does next depends on the type of SQL statement executed.
Type of SQL statement:
| Proceed to:
|
SELECT or catalog function | “Step 4a: Fetch the Results”
|
UPDATE, DELETE, or INSERT
| “Step 4b: Fetch the Row Count”
|
All other SQL statements
| “Step 3: Build and Execute an SQL Statement” (this topic) or “Step 5: Commit the Transaction”
|