Transaction Control ODBC programs often assume that each SQL statement is a logical unit of work. The setting that controls this is AUTOCOMMIT. For compatibility, the DB2 default setting is 1, which forces a commit (or rollback) for every ODBC function call. To execute multiple ODBC calls in a single logical unit of work (LUW), you must override the setting either in the initialization file or using the SQLSetConnectAttr() or SQLSetEnvAttr() functions. The SQLEndTran() function is used to commit or rollback an LUW for one or more connections. SQLEndTran() takes a HandleType and Handle along with a CompletionType of SQL_COMMIT or SQL_ROLLBACK. SQLRETURN SQLEndTran (SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT CompletionType); If the HandleType is SQL_HANDLE_ENV, DB2 will attempt to commit or roll back for each connection handle that was created for the environment handle. If the HandleType is SQL_HANDLE_DBC the commit or rollback will be done only for the specified connection. |
Team-Fly |
Top |