Progress
Programming
Handbook
Applications in a Multi-user Environment
Suppose there are two departments, Shipping and Receiving, that are using the same database. When they ship an order, the Shipping Department subtracts the number of items shipped from that item’s on–hand value. When it receives inventory from a vendor, the Receiving Department adds the number of items received to that item’s on–hand value.
Consider the case where the number of parkas on hand is 67. The Shipping Department ships 20 parkas and the Receiving Department receives 10 parkas. The number of parkas on hand is now 57 (67 on–hand – 20 shipped + 10 received = 57).
Figure 13–1 shows how this simple situation, when performed with no special multi-user controls, can produce a very different result from the obvious one you expect.
Figure 13–1: Multi-user Update Scenario Without Locks
![]()
Examine what happens if you do not take any special steps to handle multiple users accessing the same database. The points below correspond to the numbers in Figure 13–1.
- The Shipping Department ships an order for 20 parkas (item number 27).
- The Shipping Department gets the parka record from the item table. In that record, the value of the on–hand field is 67.
- The Receiving Department receives 10 parkas (item number 27).
- The Receiving Department also gets the parka record from the item table. In that record, the value of the on–hand field is 67.
- The Shipping Department subtracts 20 from the on–hand value, and returns the record to the database. The on–hand value of the parka record in the database is now 47.
- The Receiving Department adds 10 to the on–hand value of 67 and returns the record to the database. That record overwrites the record written by the Shipping Department, causing the on–hand value of the parka record in the database to be 77.
The database indicates that there are 77 parkas on hand instead of 57. It is as if the Receiving Department never updated the database.
Scenarios like this occur often in a multi-user environment and, for that reason, Progress supplies services to make sure that the data in your database is accurate.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |