Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Commit after Try/Catch
Message
De
25/08/2021 12:15:07
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Commit after Try/Catch
Divers
Thread ID:
01682165
Message ID:
01682165
Vues:
69
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
Répondre
Fil
Voir

Click here to load this message in the networking platform