Unlock (27)
The Unlock operation (B_UNLOCK) unlocks one or more records that have been locked explicitly (that is, the records were locked using a lock bias of +100, +200, +300, or +400). The Unlock operation releases locks held by the specified position block; therefore, if you have the same file opened more than once, you must issue an Unlock for each position block before the record is completely unlocked. Similarly, each client that holds a lock on records in the file must issue an Unlock before the record is completely unlocked.
Parameters
Op Code
Pos Block
Data Buf
Data Buf Len
Key Buffer
Key Number
Sent
Returned
Prerequisites
You must have at least one record lock.
Procedure
►
To unlock a single-record lock, follow these steps:
1
Set the Operation Code to 27.
2
Pass the Position Block for the file that contains the locked record.
3
Set the Key Number to a non-negative value.
►
To unlock a record locked by a multiple-record lock, first retrieve the 4-byte position of the record to unlock by issuing a Get Position operation (22) for that record. Then, issue the Unlock operation as follows:
1
Set the Operation Code to 27.
2
Pass the Position Block for the file that contains the locked record.
3
Store (in the Data Buffer) the 4-byte position that the transactional interface returns.
4
Set the Data Buffer Length to 4.
5
Set the Key Number parameter to -1.
►
To unlock all the multiple record locks on a file, follow these steps:
1
Set the Operation Code to 27.
2
Pass the Position Block for the file that contains the multiple locks.
3
Set the Key Number parameter to -2.
Result
If the Unlock operation is successful, the transactional interface releases all the locks that the operation specified.
If the Unlock operation is unsuccessful, the transactional interface returns a nonzero status code—most likely, Status Code 81.
Positioning
The Unlock operation has no effect on positioning.