COBOL Manual for TNS and TNS/R Programs
Disk Input and Output
HP COBOL Manual for TNS and TNS/R Programs—522555-006
28-35
Files With Alternate Keys
•
The specifications in the OPEN statement, or the attributes derived during the
open operation by some other means (such as from a TACL ASSIGN command),
conform to:
°
The open mode is INPUT or OUTPUT.
°
If the open mode is INPUT, the exclusion mode is PROTECTED or
EXCLUSIVE.
°
If the open mode is OUTPUT, the exclusion mode is EXCLUSIVE.
If all of the preceding qualifications are satisfied at run time, HP COBOL Fast I-O is
used only if memory resources are available. For a file opened for output, the loader
creates the file. The loader is also used by FUP, SQL/MP, and other products. The
loader manages its own extended data segment to write the file. The loader requires
local storage, which is allocated by the run-time system. The amount of local storage is
approximately 800 bytes (the exact amount depends on the type of the file and other
factors). If the necessary storage is not available, the OPEN statement returns file
status “07” and buffered cache is used to write the file.
For a file opened for input, HP COBOL Fast I-O allocates space for double buffering
from a buffer pool that is in its own extended data segment and is of a fixed size. Buffer
size is determined by multiplying the number in the RESERVE clause by the data block
size of the file (to see this size, use the command FUP INFO file-name, DETAIL).
Then, based on various factors such as the maximum transfer allowed, a read buffer
size that is not larger than 30,720 bytes is selected. The total space allocated from the
buffer pool is twice the read buffer size. If there is not enough space (as when several
files are opened for input using HP COBOL Fast I-O at the same time), the OPEN
statement returns file status “07” and sequential block buffering is used for the file.
The buffer pool space returns to the pool when the file is closed. The SAME AREA
clause has no effect on allocation or deallocation from this buffer pool.
If the file is being created and the maximum file size is exceeded, the corrupt bit is set
in the file header and the program terminates abnormally. Attempting to open the file
causes a file system error. If the file is sequential, you can use FUP to clear the corrupt
bit and read what was written to the file (all of the records you released with WRITE will
probably not be there). If the file is relative or indexed, the file is unusable.
Files With Alternate Keys
You can improve the performance of alternate-key file access by:
•
Declaring Null Values for Alternate Keys
•
Making the Main File Entry-Sequenced or Relative
•
Not Updating the Alternate-Key File Automatically
Note. HP COBOL Fast I-O is not recommended for an indexed file that has had many records
inserted or deleted since it was created. If you want to use HP COBOL Fast I-O on such a file,
first use FUP RELOAD to reorganize it.