transaction levels

Adri
Member Posts: 8
Dear reader,
We have to following problem:
when we do a stock conversion this does the following:
first negative adjustment (commit)
then check if there is no other costs booked on the stock (commit)
make positive adjustment with the total costs (commit)
These are three different processes.
Sometimes, when the positive adjustment is done there is a 'locked by another user' and this part is undone. The situation then is, that the negative adjustment is done, the check as well, but the positive is not. In short: The piece has disappeared.
Is it possible to make one transaction which undoes everything when an error occurs in the second or third part?
Kind regards,
Adri
We have to following problem:
when we do a stock conversion this does the following:
first negative adjustment (commit)
then check if there is no other costs booked on the stock (commit)
make positive adjustment with the total costs (commit)
These are three different processes.
Sometimes, when the positive adjustment is done there is a 'locked by another user' and this part is undone. The situation then is, that the negative adjustment is done, the check as well, but the positive is not. In short: The piece has disappeared.
Is it possible to make one transaction which undoes everything when an error occurs in the second or third part?
Kind regards,
Adri
0
Best Answers
-
Hi @Adri ,
As I got your question, you have 2 options here:
1. Get rid of intermediate commits and make the big one in the end;
2. Manually (in the code) roll back previous commited transactions (creating corrective entries) in the case of error.
Hope my suggestions are useful for you. If not, we can discuss your issue to find more appropeiate way.Let's go!5 -
each commit prevents the roll back of its process. so unfortunately it doesn't work like the way you hope.6
Answers
-
Hi @Adri ,
As I got your question, you have 2 options here:
1. Get rid of intermediate commits and make the big one in the end;
2. Manually (in the code) roll back previous commited transactions (creating corrective entries) in the case of error.
Hope my suggestions are useful for you. If not, we can discuss your issue to find more appropeiate way.Let's go!5 -
but why 3 different processes? they seem strictly related with each other. using commit with this kind of procedure is higly problematic.0
-
It might be a leftover from old days when a single write locked the whole table. COMMITs were used to improve write concurrencySlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
The 3 existing processes are standard processes which are reused. Unfortunately we cannot alter these (not allowed to compile, license issue)
I hope it was possible to have to following construction:
DO TRANSACTION
process 1 (which processes and commits)
process 2 (which processes and commits)
process 3 (which processes and commits)
END TRANSACTION
And when something goes wrong in one of the three commits it would roll back all.
0 -
each commit prevents the roll back of its process. so unfortunately it doesn't work like the way you hope.6
-
@Adri , COMMIT is called so because it commits transaction. Please, refer the NAV help.
Only one thing I can advice you is to copy standard functionality to new objects in available range fpr development, and replace calls in the system. But be aware that it's bad practise.Let's go!0 -
Thank you all for your help! I am quite new in C/AL, but programmed in other languages.
@Logger: There are programming languages who only commit when the transaction is finished. You can assign/commit anything at any time, but it is writen to the database then the transaction has finished. With for example "progress" (also a 4GL language) you can do as described above.
In "Progress" the commit 'writes' the database changes, but when something is wrong everything is rolled back. I hoped in C/AL this was possible as well.
1 -
There are programming languages who only commit when the transaction is finished.
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions