Handling transactions

If the CONNECT statement with the WITH CONCURRENT TRANSACTION clause has established the connection, the application can switch to another connection even if the current connection contains an active transaction.

For connections that are not established with the CONNECT...WITH CONCURRENT TRANSACTION statement, the application must end the active transaction before it switches to another connection. Any attempt to switch while a transaction is active causes the CONNECT or SET CONNECTION statement to fail (error number -1801). The transaction in the current connection remains active.

To maintain the integrity of database information, explicitly end the active transaction in one of the following ways:
  • Commit the transaction with the COMMIT WORK statement to ensure that the database server saves any changes that have been made to the database within the transaction.
  • Roll back the transaction with the ROLLBACK WORK statement to ensure that the database server backs out any changes that have been made to the database within the transaction.

The COMMIT WORK or ROLLBACK WORK statement applies only to the transaction that is within the current connection, not to transactions that are in any dormant connection.