Object Version Number is not a primary key, it indicates the version of a primary key row in a table.
It certainly plays a major role in maintaining database concurrency and data integrity.
Whenever a new row is inserted into the database, the OVN number will be set to 1. When the row is updated in the database, the OVN is incremented. The number is not decremented or reset to a previous value.
When a database row is queried by the user, the database row will be transferred to the client, the existing OVN is always transferred with the other attributes. If the object is modified by the client then this OVN will be incremented and saved back to the server, then the current server OVN is compared with the value passed from the client.
1. If the two OVN values are same, then the row on the server is in the same state as when the attributes transferred to the client. As no other changes have occurred, the current change request can continue and OVN is incremented.
2. If the two values are different, then another user has already changed and committed the row on the server. The current change request is not allowed because there are modifications the other user mode may be overwritten and lost.
Note: Database locks are used to prevent another user from overwriting uncommitted changes.
Hence, using OVN number, the users can perform change requests with out holding long term database locks. For instance, the users can connect to the server, query ( transfer) the database row to the client. Disconnect from the server. When the user connects to the server back and commits the changes he/she has done, the only OVN comparison is enough to check the data integrity and no need of long term database locks.
When the row being processed does not have the correct object version number, the application error HR_7155_OBJECT_LOCKED is raised. This error indicates that a particular row has been successfully changed and committed since you selected the information. To ensure that the other changes are not overwritten by mistake, re–select the information, reapply your changes, and resubmit the changes.