COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-248
START
Next READ After a START with POSITION Might Fail
When you use the POSITION phrase, there is no guarantee that the record you
specify actually exists. In this aspect, the start-with-position operation differs from
the ordinary COBOL start operation. The positioning operation merely sets the file
position indicator to the file location where the record can be found if it exists;
therefore, the invalid-key condition does not occur when the record does not exist.
Instead, the first subsequent sequential READ statement encounters the at-end
condition (if the physical end of the file has been reached, or if the logical end of
file associated with the generic positioning mode has been reached).
Determining Key Value of Last Record of an Indexed or Queue File
To determine the key value of the last record of an indexed or queue file, which is
especially important when using the READ REVERSED statement, move HIGH-
VALUES to the key and then use the START statement with the relationship
LESS THAN. START LESS THAN positions the indexed file so that a READ NEXT
or READ REVERSED statement accesses the last record in the file.
Table 9-11. Using the POSITION and KEY Phrases
Position-Key Key
Length Used and
Restriction Effect
Relative key
(ORGANIZATION
RELATIVE)
Alternate or
alternate(1:n )
Relative key
length (entire alternate)
+ 4 < 254
4 (which is the length of
the relative key)
Full value of alternate
AND of relative used
Relative key used alone
Prime key
(ORGANIZATION
INDEXED)
Alternate or
alternate (1:n )
Prime key
length (entire alternate)
+ length (prime) < 254
length (prime)
Full value of alternate
AND of prime used
Prime key used alone
Alternate key
(ORGANIZATION
RELATIVE or
INDEXED)
Same alternate
or alternate (1:n )
Full alternate must be
unique (no
DUPLICATES) < 254
Full value of alternate
used alone
Example 9-65. START Statement for Indexed File (page 1 of 2)
SELECT RECEIVABLES-MASTER ASSIGN TO "RECMAST"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS INVOICE-NUMBER
ALTERNATE RECORD KEY IS COMPANY-NAME
WITH DUPLICATES.
...