Get Key (+50)
The Get Key bias allows you to perform a Get operation without actually retrieving a data record. You can use Get Key to detect the presence of a value in a file. A Get Key operation is generally faster than its corresponding Get operation. You can use the Get Key operation with any of the following Get operations:
Parameters
The parameters are the same as those for the corresponding Get operation, except that the transactional interface ignores the Data Buffer Length and does not return a record in the Data Buffer.
Prerequisites
The prerequisites for a Get Key operation are the same as those for the corresponding Get operation.
Procedure
1
2
The transactional interface does not allow Delete or Update operations after a Get Key operation (+50). Before the transactional interface performs Update or Delete operations, it compares the current usage count of the data page it intends to modify with the usage count of the data page when the record was read. To obtain the usage count, the transactional interface must read the data page.
Because the Get Key operation does not read the data page, no usage count is available for comparison on the Update or Delete. The Update or Delete fails because the transactional interface cannot perform its passive concurrency conflict checking without the compare. When the Update or Delete fails, the transactional interface returns Status Code 8.
Result
If the transactional interface finds the requested key, it returns the key value in the Key Buffer and Status Code 0. Otherwise, the transactional interface returns a status code indicating why it cannot find the key value.
Positioning
The Get Key operation establishes the current positioning in a similar manner to the corresponding Get operation. However, when a Get Key operation involves a key that allows duplicates, the transactional interface ignores the duplicate instances of the current retrieved key value. After a Get Key operation, the logical previous position points to the record containing the previous lesser key value. The logical next position points to the record with the next greater key value.
For example, assume you perform a Get Key/Get Equal operation (55) on a last name key that contains eight occurrences of Smith and a single Smythe. The logical next position does not point to the next Smith, but to Smythe.
Because a Get Key operation does not positively identify any one record, the transactional interface does not allow an Update or Delete operation to follow a Get Key operation.