When you submit a transaction that changes a segment with a MODIFY, a Maintain, or an HLI program, SU employs a procedure called change/verify protocol. If more than one user tries to change a segment instance at the same time, change/verify protocol determines which transaction is accepted. A description of how the change/verify protocol interacts with your requests for changes to database records follows:
If the current value matches the original value, no one has changed the instance, and FOCUS changes the instance in the database using the copy from your source machine.
If the values differ, the FOCUS Database Server signals a conflict and rejects the source machine copy, because another user who requested the same instance at the same time has already changed it.
The following example illustrates change/verify protocol by tracing the execution of a FOCUS MODIFY request. The same concepts apply to HLI programs:
MODIFY FILE EMPLOYEE PROMPT EMP_ID PAY_DATE MATCH EMP_ID ON NOMATCH REJECT ON MATCH CONTINUE MATCH PAY_DATE ON NOMATCH REJECT ON MATCH TYPE "CURRENT GROSS:<D.GROSS" ON MATCH PROMPT GROSS ON MATCH UPDATE GROSS ON MATCH TYPE "UPDATED!" DATA
When you execute this procedure, you are prompted for an employee ID and pay date. Enter:
EMP_ID = 071382660
PAY_DATE = 990831
The source machine forwards the employee ID value to the FOCUS Database Server, which retrieves the instance with this ID and saves it. It also makes a copy for the source machine. When the source machine receives its copy, it forwards the pay date to the FOCUS Database Server, which retrieves the segment instance with PAY_DATE = 990831 and GROSS = 916.67.
The FOCUS Database Server saves these values and sends a copy to your source machine, which then prompts you for a new GROSS value, to which you respond:
GROSS = 1050.35
Your machine updates its copy of the instance with the new GROSS value, 1050.35.
SU sends your new value to the FOCUS Database Server, which compares the current database value with the original value you retrieved (916.67). If another user already changed the value and they do not match, your transaction is rejected and SU signals a conflict.
When several users try to change the same instance in a centrally controlled database at the same time, FOCUS accepts only the first transaction, rejecting all others. Users can always repeat the transaction after they are made aware of the changes that were made by other users. By reentering the same key values, they will receive a fresh copy of the instance and can update that.
Change/verify protocol retains only the current transaction. When you rematch on the keys, the current transaction becomes the new match subject. For example, when you retrieve data in one MODIFY case and then update it in another, verification is only performed on the second MATCH operation. Similarly, only the last record retrieved in multi-record processing (through a HOLD in MODIFY or a FOR NEXT in MAINTAIN) is retained. The current position in the database changes with each record retrieval or update.
Information Builders |