IBM Books

Call Level Interface Guide and Reference


Making use of Dynamic SQL Statement Caching

Note:This section is only relevant when connecting to a server that does not have a global statement cache. The application should not make use of dynamic SQL statement caching when connection to a server that has a global dynamic statement cache, such as DB2 Universal Database. See Making use of the Global Dynamic Statement Cache for more details.

To make use of dynamic caching, (when the server caches a prepared version of a dynamic SQL statement), the application must use the same statement handle for the same SQL statement.

For example, if an application routinely uses a set of 10 SQL statements, 10 statement handles should be allocated and associated with each of those statements. Do not free the statement handle while the statement may still be executed. (The transaction can still be rolled back or committed without affecting any of the prepared statements). The application would continue to prepare and execute the statements in a normal manner, DB2 CLI will determine if the prepare is actually needed.

To reduce function call overhead, the statement can be prepared once, and executed repeatedly throughout the application.
Note:If the server does not support dynamic caching, DB2 CLI will internally issue prepares for the statement when necessary.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]