SQLEndTran--Request a COMMIT or ROLLBACK

Purpose

Specification: DB2 CLI ODBC ISO CLI

SQLEndTran() requests a COMMIT or ROLLBACK operation for all active operations on all statements associated with a connection.

Syntax

SQLRETURN   SQLEndTran       (SQLSMALLINT        HandleType,
                              SQLHANDLE          Handle,
                              SQLSMALLINT        Completion Type);

Function arguments

Table 42. SQLEndTran arguments

Data type Argument Use Description
SQLSMALLINT HandleType input Handle Type.
SQLHANDLE Handle input Connection handle.
SQLSMALLINT CompletionType input How to complete the active operations associated with a connection.

Usage

HandleType
Handle type identifier. Only SQL_HANDLE_DBC (a connection handle) is allowed.

Handle
The handle, of the type indicated by HandleType.

CompletionType
One of the following two values:

In manual-commit mode, SQLEndTran() must be called before calling SQLDisconnect(). If SQLEndTran() is not called before SQLDisconnect(), the operations that updated the database (since the last transaction started) are rolled back.

When a ROLLBACK is performed, all the statement handles are cleared.

If the application crashes or terminates prematurely during use in manual mode, the updates since the last COMMIT are lost. SQLEndTran() must be called before calling disconnect.

Return codes

Diagnostics

Table 43. SQLEndTran SQLSTATEs

SQLSTATE Description Explanation
58004 Unexpected system failure. Unrecoverable system error.
HY001 Memory allocation failure. DB2 CLI is unable to allocate memory required to support execution or completion of the function.
HY013 Unexpected memory handling error. DB2 CLI is unable to access memory required to support execution or completion of the function.
HY014 No more handles. DB2 CLI is unable to allocate a handle due to internal resources.

Restrictions

None.

Related reference