TurboIMAGE/XL Database Management System Reference Manual MPE/iX V6.5 (30391-90011)

Chapter 4 123
Using the Database
Using the Locking Facility
Add a New Customer
1. DBLOCK the CUSTOMER data set or the whole database.
2. DBPUT new data entry in CUSTOMER data set.
3. DBUNLOCK.
Note that TurboIMAGE/XL requires a data set or database lock to cover the addition of an
entry to a master data set.
Update Inventory Information
1. DBLOCK INVENTORY: STOCK# = 6650D22S. (Alternatively, the INVENTORY set or
the whole database can be locked.)
2. DBFIND and DBGET the data entry that is locked in step 1.
3. Compute new UNIT-COST = UNIT-COST + .12
4. UNIT-COST.
5. DBUPDATE the data entry that is locked.
6. DBUNLOCK.
Insert a New Product with a New Supplier
1. DBLOCK the PRODUCT master data set, the SUP-MASTER data set, and the data item
STOCK# = 4444A33B in the INVENTORY detail data set. (This can be done in one
DBLOCK mode 5 call.)
2. DBBEGIN.
3. DBPUT a new data entry in PRODUCT master data set. (For example: 4444A33B
CALIPER).
Table 4-4. Locking in Shared-Access Environments
Action Recommended Locks
Chained DBGET calls Lock all data entries in the chain. This usually requires
one lock descriptor.
Serial DBGET calls Lock the data set.
Update a data entry (DBUPDATE) Lock the data entry before calling DBGET to read the data
entry. Unlock after the update.
Directed reads (DBGET calls) These are not recommended in a shared environment.
Lock the data set before determining which data entry is
needed.
Add a data entry to a detail data set
(DBPUT)
Any lock which covers this data entry, but preferably
uses the data item that was decided on as the "lock item"
for the data set.
Add to or delete from a master data
set (DBPUT and DBDELETE)
Lock the data set or database. This is mandatory if the
database is open in access mode 1.