There is no builtin SQL function that can tell you whether you are inside an explicit transaction. I suppose you could write a UDF that used the sqlite3_get_autocommit API (<https://sqlite.org/c3ref/get_autocommit.html>) to return whether or not you were in autocommit or an explicit transaction. However, why would you want to rollback a transaction if you do not know that there is a transaction in progress? Surely the application issuing the command knows whether or not a transaction is in progress and can respond appropriately to an ABORT error?