Disable cursor hold behavior for more efficient resource use

DB2® ODBC can more efficiently use resources that are associated with statement handles if you disable cursor-hold behavior for statements that do not require it.

To disable cursor-hold behavior on a statement handle, call SQLSetStmtAttr() with the SQL_ATTR_CURSOR_HOLD attribute set to SQL_CURSOR_HOLD_OFF. You can also set the cursor-hold behavior for an entire data source through the initialization file.

The SQL_ATTR_CURSOR_HOLD statement attribute is the DB2 ODBC equivalent to the CURSOR WITH HOLD clause in SQL. DB2 ODBC cursors exhibit cursor-hold behavior by default.

Important: Many ODBC applications expect a default behavior in which the cursor position is maintained after a commit. Consider such applications before you disable any cursor-hold behavior.