Rolling back transactions

I understand that there's no rollback function available for me to call directly if I want to force the transaction to roll back.  What would be a good way to get around this limitation?

I have a transaction that requires multiple database operations and an external API call.  Sometimes, the external API call fails.  When this happens, I would like to roll back the transaction.

Shall I issue a database transaction that I know for sure will fail the trigger the roll back?
Working with APIs
4 replies