SQLTransact() 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 SQLTransact() (whichever is the most recent) are committed or rolled back.
If a transaction is active on a connection, the application must call SQLTransact() before it can disconnect from the database.
SQLRETURN SQLTransact (SQLHENV henv, SQLHDBC hdbc, SQLSMALLINT fType);
Data type | Argument | Use | Description |
---|---|---|---|
SQLHDBC | hdbc | Input | Database connection handle. If hdbc is set to SQL_NULL_HDBC, then henv must contain the environment handle that the connection is associated with. |
SQLHENV | henv | Input | Environment handle. If hdbc is a valid connection handle, henv is ignored. |
SQLSMALLINT | fType | Input | The wanted action for the transaction. The
value for this argument must be one of:
|
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 SQLTransact() has no effect on the database server and returns SQL_SUCCESS.
SQLTransact() 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 DBMS product information for more information about transaction logs and other transaction management tasks.
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. |
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. |
Refer to the example in SQLFetch - Fetch next row