Guardian Procedure Calls Reference Manual (G06.25+)

Guardian Procedure Calls (H-K)
Guardian Procedure Calls Reference Manual522629-013
7-61
KEYPOSITION[X] Procedures
(Superseded by FILE_SETKEY_ Procedure)
Following an approximate KEYPOSITION to key-value = “AB”, key-length
= 2, and
positioning-mode = read-reverse, a call to READ would return record
number 1 from the set of records shown above. The same call to KEYPOSITION,
but with position-to-last also specified, would result in record number 3 being
returned from READ.
A similar situation arises when you read a key-sequenced file with duplicate
alternate keys. When an alternate-key file allows duplicate alternate keys that are
ordered by primary-key value (the standard ordering method),
key-value should
be thought of as having two parts: the alternate-key value and the primary-key
value. You can specify both parts or you can specify the alternate-key value only.
Consider the following records:
Following an approximate KEYPOSITION to
key-value = “BBB”, key-length =
3, and
position-mode = read-reverse, the position would be just before record 1
and after record 0. This position results because, when
key-value is specified
as “BBB”, the primary-key part is null (the lowest possible key value). A call to
READ would return record 0. The same call to KEYPOSITION, but with position-
to-last specified, would result in record 2 being returned from READ.
For the primary key of relative and entry-sequenced files, the
key-value
parameter to KEYPOSITION is a 4-byte string containing a doubleword record
number value. When read-reverse and approximate positioning are specified,
initial positioning is performed to the first record whose record number is equal to
or less than the record number passed in
key-value. Records are returned in
descending record number order from successive calls to READ. The position-to-
last option has no effect (is ignored) for a KEYPOSITION to an exact record
number in a relative or entry-sequenced file.
Positioning to the last record in a file with KEYPOSITION is accomplished by
specifying approximate mode, read-reverse, and position-to-last in the
positioning-mode parameter, and setting key-length to 0. A subsequent call
to READ will return the last record in the file.
Read Reverse and SAVEPOSITION
2ABB
3ABC
4ACA
Record Number Alternate Key Primary Key
0AAA30
1BBB10
2BBB20
3 CCC 40
Record Number Key Value