Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Commit after Try/Catch
Message
From
25/08/2021 12:15:07
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Commit after Try/Catch
Miscellaneous
Thread ID:
01682165
Message ID:
01682165
Views:
68
After a process, we decide if we can commit using XACT_STATE=1. When an exception occurs, this will put -1 into XACT_STATE.

However, in some parts of the code, we have exceptions which we control. For example, when we try to convert a text into a date, if it doesn't work, an exception occurs. However, because it is inside a TRY/CATCH, the code can continue. For that particular scenario, we initialize with a blank date.

Then, we realized the commit still fails because XACT_STATE=-1. Thus, we replaced that condition with a variable such as CommitReadyToBeExecuted. However, the commit will not work because an exception occured before, even if we controlled it.

How can we reset XACT_STATE to 1 or force the commit to be executed even if we had an exception?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Reply
Map
View

Click here to load this message in the networking platform