SQLEndTran() commits or rolls back the current transaction in the connection.
All changes to the database performed on the connection since connect time or the previous call to SQLEndTran() (whichever is the most recent) are committed or rolled back.
If a transaction is active on a connection, the application must call SQLEndTran() before it can disconnect from the database.
SQLRETURN SQLEndTran (SQLSMALLINT hType, SQLINTEGER handle, SQLSMALLINT fType);
Data type | Argument | Use | Description |
---|---|---|---|
SQLINTEGER | handle | Input | Handle to use when performing the COMMIT or ROLLBACK. |
SQLSMALLINT | fType | Input | Wanted action for the transaction. The value
for this argument must be one of:
|
SQLSMALLINT | hType | Input | Type of handle It must contain SQL_HANDLE_ENV or SQL_HANDLE_DBC. |
Completing the transaction with SQL_COMMIT_HOLD or SQL_ROLLBACK_HOLD still commits or rolls back the database changes, but does not cause cursors to be closed.
If no transaction is currently active on the connection, calling SQLEndTran() has no effect on the database server and returns SQL_SUCCESS.
SQLEndTran() might fail while executing the COMMIT or ROLLBACK due to a loss of connection. In this case the application might be unable to determine whether the COMMIT or ROLLBACK has been processed, and a database administrator's help might be required. Refer to the Database Management System (DBMS) product information for more information about transaction logs and other transaction management tasks.
When using either SQL_SAVEPOINT_NAME_ROLLBACK or SQL_SAVEPOINT_NAME_RELEASE, you must already have set the savepoint name using SQLSetConnectAttr.
SQLSTATE | Description | Explanation |
---|---|---|
08003 | Connection not open | The hdbc is not in a connected state. |
08007 | Connection failure during transaction | The connection associated with the hdbc fails during the processing of the function during the processing of the function and it cannot be determined whether the requested COMMIT or ROLLBACK occurs before the failure. |
58004 | System error | Unrecoverable system error. |
HY001 | Memory allocation failure | The driver is unable to allocate memory required to support the processing or completion of the function. |
HY010 | Function sequence error | SQL_SAVEPOINT_NAME_ROLLBACK or SQL_SAVEPOINT_NAME_RELEASE is used, but the savepoint name is not established by calling SQLSetConnectAttr() for attribute SQL_ATTR_SAVEPOINT_NAME. |
HY012 | Transaction operation state that is not valid | The value specified for the argument fType is neither SQL_COMMIT nor SQL_ROLLBACK. |
HY013 * | Memory management problem | The driver is unable to access memory required to support the processing or completion of the function. |