Always Perform Edits in a Locked State
To make application logic multi-user safe, a reread of data from disk is required before data in an active record buffer is changed. This ensures that no other user or process has changed the data since it was retrieved from disk. To create a multi-user safe program, the programmer who wants to edit data should always reread after finding the record to edit or find records to edit in a locked state.
Programs that do not use multi-user safe code will generate the error DFERR_EDIT_WITHOUT_REREAD (4155). If you have a program that generates this error, it should be adjusted to become multi-user safe. While this adjustment is ongoing, there may be a need to use the program anyway. It is possible to suppress the error; however, be aware that running a program that is not multi-user safe can result in data corruption. You should make your code multi-user safe and switch off the error suppression.
You can suppress the DFERR_EDIT_WITHOUT_REREAD error by setting the DF_REREAD_REQUIRED global attribute to false. You can do this in the program’s code or by setting an environment variable DFREREADOPT to any value. The code below shows a procedure that adjusts all Vendor records in a multi-user unsafe way without generating the DFERR_EDIT_WITHOUT_REREAD error.
Procedure AdjustAllVendorsInAMultiUserUnsafeWay
Boolean bOrgRereadRequired
Open Vendor
Get_Attribute DF_REREAD_REQUIRED To bOrgRereadRequired
Set_Attribute DF_REREAD_REQUIRED To False
Clear Vendor
Find GT Vendor By 1
While (Found)
Move "TEST" To Vendor.Name
SaveRecord Vendor
Find GT Vendor By 1
End
Set_Attribute DF_REREAD_REQUIRED To bOrgRereadRequired
End_Procedure // AdjustAllVendorsInAMultiUserUnsafeWay
The code above can be adjusted in two ways to make it multi-user safe. You can make it one big transaction or alternatively make every edit a separate transaction. The best choice depends on the needs of the edit operation.
Procedure AdjustAllVendorsInOneTransaction
Open Vendor
Begin_Transaction
Clear Vendor
Find GT Vendor By 1
While (Found)
Move "TEST" To Vendor.Name
SaveRecord Vendor
Find GT Vendor By 1
End
End_Transaction
End_Procedure // AdjustAllVendorsInOneTransaction
Procedure AdjustEachVendorsInSeparateTransactions
Open Vendor
Clear Vendor
Find GT Vendor By 1
While (Found)
Begin_Transaction
Reread
Move "TEST" To Vendor.Name
SaveRecord Vendor
Unlock
End_Transaction
Find GT Vendor By 1
End
End_Procedure // AdjustEachVendorsInSeparateTransactions