CHAPTER 1 - Introduction to X++
CHAPTER 2 - X++ Control Statements
CHAPTER 3 - Objects and Classes
CHAPTER 4: Accessing the Database
CHAPTER 5: Exception Handling
CHAPTER 6: Security for Developers
Lesson 4 – Optimistic Concurrency Exceptions
Optimistic Concurrency Exceptions
The optimistic concurrency check (OCC) is a performance enhancing function within Microsoft Dynamics AX. It presumes that any record retrieved from the database is not updated, until it is actually proven to be updated by the database. This means that fewer locks have to be placed on records in the database. This allows for faster access for other users.
This also means that one user can update a record after another user has retrieved it from the database. This can cause data inconsistency. If the second user then also tries to update the record, an UpdateConflict exception is thrown. The system does this by comparing the recVersion field on the record buffer at runtime and the actual record in the database. The recVersion field value is changed every time that an update is successfully made to a record.
Following are the advantages of using OCC:
- Fewer resources are used to hold the locks during the update process.
- Records are locked for a shorter length of time.
- Records remain available for other processes to update if they have been selected from the database but haven’t yet been updated.
The disadvantage of using OCC is that the update can fail if another process updates the same record. If the update fails, it must be retried. This can lead to a reduction in database performance.