
Error handling and Database Transactions
@@TranCount is a bit weird - looked into this.
nested / open transactions at that point (God knows why - maybe someone can
answer that?).
So.. you can't do any further tranaction stuff based on this value - the
only thing you can do is rollback ALL nested transactions.
Basically if any transaction fails, you must rollback all of them going up
the nested hierarchy.
At the very top level (a DLL I presume) you should be able to collect the
transaction failure reason - only need to really process the deepest level
error - and base your actions on that.
Rasing an error is *your* decision in whatever you create - generally, the
top level DLL should be able to take appropriate actions to make sure the
data is not corrupted and then return a status value (could be an enumerated
constant) or a success value. Raising errors to ASP pages is an absolute
nightmare so make sure you process possible failures after every actionable
call.
I can't really go much further without getting drawn into your development
methods and component.
Personally, I use the DLL for the transactions and leave the transact stuff
out of the SP's cos it's a lot easier to handle.
I hope this helps a bit.
Chris Barber.
Chris,
Thanks for your reply.
The only way I could see this working is if you keep tabs on how many
transactions you have started at a particular time and then if an error
occurrs, you roll them all back in the function that caused the error.
Then make sure every function returns the fact that it has failed so it
can be dealt with.
Otherwise you need to raise errors back to the function that started the
transaction and have it to the Rollback and error display which is what
I was trying to get away from.
Any tips on how to determine how many transactions are open,
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!