Hi,
what's wrong with what i wrote?
try { ttsbegin; --logic if(flag) { -- logic ttscommit; } else { ttsabort; } } catch { }
Hi JuniorAX,
Could you, please, explain why you want to use ttsAbort?
Another option could be to throw an error in case if "flag" variable is not set. It will also abort all transactions
try { ttsbegin; --logic if(!flag) { throw error("Not flag"); } -- logic for flag ttscommit; } catch { }
Hi Sergie,
I used ttasbort because i only want ttscommit to happen if the flag is truee, so if i don't put ttsabort, i guess will get an error because ttscommit is only inside the if condtion.
I prefer to not throw an error, but is this the only option?
The best practice is not to use ttsAbort if it's really necessary and use throw instead.
docs.microsoft.com/.../x-standards-ttsbegin-and-ttscommit
Other than what was already said that you should avoid ttsabort in most cases, the code you wrote should technically work just fine. I'll ask the team to review this best practice but it will be super low priority to be honest.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 2,188
André Arnaud de Cal... 868 Super User 2025 Season 2
Sohaib Cheema 593 User Group Leader