Guidance on transactions and exception handling

You can use the useTransaction() and startTransaction() operations to run scripting code inside a transaction. Running related code inside a transaction provides you an ability to ensure atomic execution of the related code. You can also use transactions in long-running jobs such as import or report jobs for periodic commit of the changes to the database.

When you use transaction-related operations, you must take adequate care to ensure that the script code does not unintentionally disrupt an already active transaction. Use of useTransaction() script operation results in commit of an already active transaction. Unless the intention is to commit the existing transaction, you must not start useTransaction() if a transaction exists.

Using startTransaction() results in a rollback of an already active transaction only if an error occurs. In such a case, the exception must be propagated to the owner of the active transaction.

You can use inTransaction() script operation to programmatically determine whether the code is running within an active transaction to ensure that it does not disrupt an existing transaction.

In addition, IBM® Product Master prevents disruption of the active transaction by scripts to ensure consistency of the Product Master operations that rely on those transactions. For more information, see Limitations on using transactions within extension points