I have 4 stored procedures, lets name them spA, spB, spC and spD.
Each of these stored procedures has a start transaction, commit and rollback.
spA is currently the parent stored procedure(SP) and within it, I am calling spB, spC, spD in respective order. Apparently, because all the SPs have commit in them, when spC fails, the DML operations performed in spB are not reverted as they are already committed and same when spD fails operations in spB and spC are not rollbacked.
The reason why I have commit in spB, spC, and spD is that later on, I might simply use either of these SPs directly to perform operations respective to the SP.
Currently, I plan on using an input bit flag to decide whether to commit the transaction. In MS SQL, there is an option to check the @@transcount, however, I am unable to find something similar in MySQL.
I was wondering if there is a better way to handle this scenario.