This topic shows a typical order of function calls in a DB2® UDB CLI application.
The function SQLAllocStmt is needed to obtain a statement handle that is used to process the SQL statement. There are two methods of statement processing that can be used. By using SQLPrepare and SQLExecute, the program can break the process into two steps. The function SQLBindParameter is used to bind program addresses to host variables used in the prepared SQL statement. The second method is the direct processing method in which SQLPrepare and SQLExecute are replaced by a single call to SQLExecDirect.
As soon as the statement is processed, the remaining processing depends on the type of SQL statement. For SELECT statements, the program uses functions like SQLNumResultCols, SQLDescribeCol, SQLBindCol, SQLFetch, and SQLCloseCursor to process the result set. For statements that update data, SQLRowCount can be used to determine the number of affected rows. For other types of SQL statements, the processing is complete after the statement is processed. SQLFreeStmt is then used in all cases to indicate that the handle is no longer needed.