4 Database Manipulation
DBLOCK (base name, qualifier, mode, status)
The parameters are:
MODES | QUALIFIER | COMMENTS |
---|---|---|
1,2,11,12 | Ignored. | Database level locks. |
3,4,13,14 | Data set name or number. | Data Set level locks. |
5,6,15,16 | String expression lock descriptor. | General-purpose lock entry level. |
DBLOCK locks the section requested if no other user currently has a conflicting lock. If the lock cannot be granted immediately and a "wait" (odd) mode is used, the request is placed in a queue to wait for access. Access is granted only after all conflicting locks ahead in the queue have been granted and released. (Although the section requested is not locked but is in queue, no other request which would lock a subsection and hold up the first request is granted. Refer to Database Locking in page 141 ).
Even mode numbers request a lock without wait; if the lock cannot be granted immediately, no lock is made. The reason for the lock failure is indicated in the condition word of the status array. The request is not queued.
If a program has a lock in effect, additional locks can be made only with even modes ("no-wait" modes). If additional locks are made with odd modes ("wait" modes), the "wait" modes are automatically changed to "no-wait" modes. If these "no-wait" modes cannot be granted, a status error is returned. Using "no-wait" modes prevents successive lock requests from causing a deadlock error. All databases currently opened are checked.
A write lock is exclusive. No other locks may be made on that section. A read lock may be made on a section that already has a read lock.
Mode | Wait | Write | Read |
---|---|---|---|
1 | yes | Entire database. | |
3 | yes | Data set. | |
5 | yes | Predicate. | |
11 | yes | Entire database. | |
13 | yes | Data set. | |
15 | yes | Predicate. | |
2 | no | Entire database. | |
4 | no | Data set. | |
6 | no | Predicate. | |
12 | no | Entire database. | |
14 | no | Data set. | |
16 | no | Predicate. |
For example, the following statement requests without wait a write lock on the data set PARTS:
100 DBLOCK (BASE$,"PARTS",4,STATUS(*))However, the following statement requests with wait a read lock on the data sets and data entries specified in the string formed by the concatenation of the lock descriptors in P$ and Q$:
110 DBLOCK (Base$,P$&Q$,15,Status(*))
Array Element | Value | Description |
---|---|---|
1 | Conditional Word | 0 for successful lock. |
2 | Descriptor Number | Number causing failure. |
1 | For successful lock in modes 1 through 4. | |
3 | 0 | If CW=20, database locked. |
1 | If CW=20, data set or data entries locked. | |
4 | Reserved | |
5 | 0 | |
6 | Bits 0 through 11 | The DBLOCK identification number 409. |
Bits 12 through 15 | The mode value used to open the database. | |
7 | Program line number | |
8 | 0 | |
9 | Mode number | The mode parameter value. |
10 | Any value | Reserved. |