DB2 Version 9.7 for Linux, UNIX, and Windows

Considerations for mixing embedded SQL and CLI

You can use CLI in conjunction with embedded static SQL in an application. Consider the scenario where the application developer wishes to take advantage of the ease of use provided by the CLI catalog functions and maximize the portion of the application's processing where performance is critical. In order to mix the use of CLI and embedded SQL, the application must comply with the following rules:

Since CLI permits multiple connections, the SQLSetConnection() function must be called prior to executing any embedded SQL. This allows the application to explicitly specify the connection under which the embedded SQL processing is performed.

If the CLI application is multithreaded and also makes embedded SQL calls or DB2® API calls, then each thread must have a DB2 context.