Determine transaction success or failure

The access method can register an end-of-transaction callback function to handle the MI_EVENT_END_XACT event, which the database server raises at the end of a transaction.

In that callback function, test the return value of the DataBlade® API mi_transition_type() function to determine the state of the transaction, as follows.
Return value for mi_transition_type() Transaction state
MI_NORMAL_END Successful transaction completion The database server can commit the data.
MI_ABORT_END Unsuccessful transaction completion The database server must roll back the table to its state before the transaction began.
Important: does not ensure uniform commit or rollback (called two-phase-commit protocol) with data in an external database server. If a transaction partially commits and then stops, inconsistencies can occur between the database server and external data.

As long as a transaction is in progress, the access method saves each original source record value before it executes a delete or update. For transactions that include both internal and external objects, the access method can include either an end-of-transaction or end-of-statement callback function to ensure the correct end-of-transaction action. Depending on the value that mi_transition_type() returns, the callback function either commits or rolls back (if possible) the operations on the external objects.

If an external transaction does not completely commit, the access method must notify the database server to roll back any effects of the transaction on the state of the virtual table.

For detailed information about the following items, see the Informix® DataBlade API Programmer's Guide:
  • Handling state-transitions in a UDR
  • End-of-transaction callback functions
  • End-of-statement callback functions