I have some "base operation" stored procedures, like BookAVehicle
and UnBookAVehicle
. They are both in a transaction.
But now I need to have a somewhat more complex stored procedure: RescheduleBooking
. It also needs to be transactional.
Now, from within ResceduleBooking
I want to call BookAVehicle
, and in this case I don't want the inner transaction to rollback.
But when I call BookAVehicle
directly, I want to keep the rollback.
Any suggestion on how to do this elegantly?
I was thinking of something along the lines of having a "wrapper" stored procedure that as a parameter takes the name of a stored procedure and only contains a transaction and a call to the parameter stored procedure.
So when I call it "directly" I call:
TransactionWrapper(BookAVehicleWithoutTrans)
and when I call it from another transaction I call:
RescheduleBooking -> BookAVehicleWithoutTrans