SQLTransact
SQLTransact#
SQLTransact requests a commit or rollback operation for all active operations on all statements associated with a connection.
Normally terminates or cancels all changed in the database made after the connection or before calling of SQLTransact().
If the transaction is in use in the connection status, an application must call SQLTransact() before disconnecting the database.
SQLTransact() has been replaced by SQLEndTran().
Syntax#
SQLRETURN SQLTransact (
SQLHENV env,
SQLHDBC dbc,
SQLSMALLINT type );
Arguments#
Data Type | Argument | In/Output | Description |
---|---|---|---|
SQLHENV | env | Input | Environment handle |
SQLHDBC | dbc | Input | Connection handle |
SQLSMALLINT | type | Input | One of the following two values. - SQL_COMMIT - SQL_ROLLBACK |
Return Values#
SQL_SUCCESS
SQL_INVALID_HANDLE
SQL_ERROR
Description#
Completing the transaction with SQL_COMMIT or SQL_ROLLBACK will have the following effects:
-
Even after SQLTransact() is called, the statement handle remains valid.
-
The bound parameter and the column binding remain alive longer than the transaction.
-
Discarding incompleted result sets.
Calling SQLTransact() when there is not transaction is currently used will return SQL_SUCCESS without any affecting the database server.
SQLTransact() may fail while Commit or Rollback is executed due to loss of connection. In this case, an application cannot judge whether commit or rollback was made. In this case the database administrator handles it manually.
Example#
< Refer to: $ALTIBASE_HOME/sample/SQLCLI/demo_tran1.cpp >
SQLTransact(SQL_NULL_HENV, dbc, SQL_COMMIT);