Procedure Division for File Input and Output (continued) [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation
COBOL/HP-UX Language Reference for the Series 700 and 800
Procedure Division for File Input and Output (continued)
The START Statement
Function
The START statement provides a basis for logical positioning within a
relative or indexed file for subsequent retrieval of records. This
statement is not available for files with sequential organization.
General Formats
Format 1 (Relative Files)
Format 2 (Indexed Files)
Note that the required relational characters ">", "<", ">=" , "<=" and
"=" are not underlined to avoid confusion with other symbols, such as >=
(greater than or equal to).
Syntax Rules
All Formats (Relative and Indexed Files)
1. File-name-1 must be the name of a relative or indexed file.
2. File-name-1 must be the name of a file with sequential or dynamic
access.
3. Data-name-1 can be qualified.
4. The INVALID KEY phrase must be specified if no applicable USE
procedure is specified for file-name-1.
________________________________________________________________________
|This rule is not enforced. (OSVS) (VSC2) (MF) |
________________________________________________________________________
Format 1 (Relative Files)
5. If the KEY phrase is specified, data-name-1 must be the data item
specified in the RELATIVE KEY phrase of the associated file control
entry.
Format 2 (Indexed Files)
6. If the KEY phrase is specified, data-name-1 can reference a data
item specified as a record key associated with file-name-1. It can
also reference any data item of category alphanumeric, subordinate
to the data item specified as a record key associated with
file-name-1, whose leftmost character position corresponds to the
leftmost character position of that record key data item.
________________________________________________________________________
|(MF) |
| |
| |
| |
|7. Split-key-name-1 can reference one or more data items, and is |
| specified as a record key associated with file-name-1. |
| |
|8. WITH SIZE specifies the number of characters in the key to be |
| used in the positioning process. |
| |
|9. Identifier-1 must be the name of an elementary integer data item |
| when used with the WITH SIZE phrase. |
| |
________________________________________________________________________
General Rules
All Formats (All Files)
1. File-name-1 must be open in the INPUT or I/O mode at the time that
the START statement is executed. (See the section "The OPEN
Statement" earlier in this chapter.)
2. If the KEY phrase is not specified, the relational operation IS
EQUAL TO is implied.
3. Execution of the START statement causes the value of the FILE
STATUS data item, if any, associated with file-name-1 to be
updated. (See the section "I/O Status" earlier in this
chapter.)
________________________________________________________________________
|(MF) |
| |
| |
| |
|4. The START statement never acquires, detects or releases record |
| locks. |
| |
________________________________________________________________________
Format 1 (Relative Files)
5. The type of comparison specified by the relational operator in the
KEY phrase occurs between a key associated with a record in the file
referenced by file-name-1 and a data item as specified in General
Rule 6.
a. If the relational operator specifies that the key must be
equal to or greater than, or greater than or equal to the
data item, then (ANS85) the file position indicator is
positioned to the first logical record currently existing in
the file whose key satisfies the comparison.
________________________________________________________________________
|(MF) |
| |
| |
| |
|b. If the relational operator specifies that the key must be less |
| than, or less than or equal to the data item, then the file |
| position indicator is positioned to the last logical record |
| currently existing in the file whose key satisfies the |
| comparison. |
| |
________________________________________________________________________
c. If the comparison is not satisfied by any record in the file,
an INVALID KEY condition exists. The execution of the START
statement will be unsuccessful, and the position of the file
position indicator will be undefined. (See the section "The
INVALID KEY Condition" in this chapter.)
6. The comparison described in General Rule 5 uses the data item
referenced by the RELATIVE KEY clause associated with file-name-1.
A RELATIVE KEY clause must be associated with a file name.
Format 2 (Indexed Files)
7. The type of comparison specified by the relational operator in the
KEY phrase occurs between a key associated with a record in the file
referenced by file-name-1 and a data item as specified in General
Rule 8. If file-name-1 references an indexed file and the operands
are of unequal size, the comparison proceeds as though the longer
one were truncated on the right so that its length is equal to that
of the shorter. All other nonnumeric comparison rules apply except
that the presence of the PROGRAM COLLATING SEQUENCE clause will have
no effect on the comparison. (See the section Comparison Of
Nonnumeric Operands in the chapter COBOL Concepts.)
a. If the relational operator specifies that the key must be
equal to or greater than, or greater than or equal to the
data item, then (ANS85) the file position indicator is
positioned to the first logical record currently existing in
the file whose key satisfies the comparison.
________________________________________________________________________
|(MF) |
| |
| |
| |
|b. If the relational operator specifies that the key must be less |
| than, or less than or equal to the data item, then the |
| file position indicator is positioned to the last logical |
| record currently existing in the file whose key satisfies |
| the comparison. If this key has duplicate entries, the |
| file position indicator is positioned to the last of these |
| entries. |
| |
________________________________________________________________________
c. If the comparison is not satisfied by any record in the file,
an INVALID KEY condition exists, the execution of the START
statement is unsuccessful, and the position of the file
position indicator is undefined. (See the section "The INVALID
KEY Condition" in this chapter.)
8. If the KEY phrase is specified, the comparison described in General
Rule 7 uses the data item referenced by data-name.
9. If the KEY phrase is not specified, the comparison described in
General Rule 7 uses the data item referenced in the RECORD KEY
clause associated with file-name-1.
10. After successful execution of the START statement, a key of
reference is established and used in subsequent Format 3 READ
statements as follows (see the section "The READ Statement"
earlier in this chapter):
a. If the KEY phrase is not specified, the prime record key
specified for file-name-1 becomes the key of reference.
b. If the KEY phrase is specified, and data-name-1 or
split-key-name-1 (MF) is specified as a record key for
file-name-1, that record key becomes the key of reference.
c. If the KEY phrase is specified, and data-name-1 or
split-key-name-1 (MF) is not specified as a record key for
file-name-1, the record key whose leftmost character position
corresponds to the leftmost character position of the data
item specified by data-name-1 or split-key-name-1 (MF)
becomes the key of reference.
11. If execution of the START statement is not successful, the key of
reference is undefined.
________________________________________________________________________
|The UNLOCK Statement |
| |
|(MF) |
| |
|Function |
| |
|The UNLOCK statement releases all record locks held by the run unit on|
|a named file. |
| |
|General Format |
| |
|Syntax Rule |
| |
|File-name must occur in the SELECT statement of the FILE CONTROL |
|entry. |
| |
|General Rules |
| |
| |
| 1. The file referenced by file-name must already be opened with |
| the OPEN statement. |
| |
| 2. The UNLOCK statement releases all record locks held by the run |
| unit on a named file. |
________________________________________________________________________
The USE Statement
Function
The USE statement specifies procedures for input-output error handling,
that are in addition to the standard procedures provided by the
input-output control system.
General Formats
Format 1 (Sequential , Relative and Indexed Files)
Format 2 (Record Sequential Files)
Format 3 (Relative And Indexed Files)
Syntax Rules
All Formats (All Files)
1. Format 1 is the ERROR declarative.
________________________________________________________________________
|Formats 2 and 3 are the LABEL declarative. (OSVS) (VSC2) |
________________________________________________________________________
2. A USE statement, when present, must immediately follow a section
header in the Declaratives Section and must be followed by a
period followed by a space.
3. The USE statement itself is never executed; it merely defines the
conditions calling for the execution of the USE procedures.
4. The files implicitly or explicitly referenced in a USE statement
need not all have the same organization or access.
Format 1 (Sequential, Relative and Indexed Files)
5. The same file-name can appear in a different specific arrangement of
the format. Appearance of a file-name in a USE statement must not
cause the simultaneous request for execution of more than one USE
procedure.
________________________________________________________________________
|(ANS85) |
|The same file-name must not appear in more than one USE AFTER |
|EXCEPTION statement within the same Procedure Division. |
________________________________________________________________________
6. The words ERROR and EXCEPTION are equivalent and can be used
interchangeably.
________________________________________________________________________
|(OSVS) (VSC2) |
| |
|Formats 2 and 3 (Record Sequential, Relative and Indexed Files) |
| |
| |
| |
|7. If both BEGINNING and ENDING are omitted, the effect is as though|
| both BEGINNING and ENDING had been specified. |
| |
| |
|Format 2 (Record Sequential Files) |
| |
| |
| |
|8. REEL and UNIT are treated as equivalent. |
| |
|9. If both FILE and REEL/UNIT are omitted, the effect is as though |
| both had been specified. |
| |
|10. Any one file name and any one OPEN mode can appear in at most |
| one declarative for each of the possible combinations of |
| BEGINNING/ENDING and FILE/REEL as shown below: |
| |
| |
| BEGINNING FILE BEGINNING REEL/UNIT |
| ENDING FILE ENDING REEL/UNIT |
| |
| |
________________________________________________________________________
General Rules
All Formats (All Files)
1. After execution of a USE procedure, control is returned to the
invoking routine.
2. Within a USE procedure, there must not be any reference to any
non-declarative procedures. Conversely, in the non-declarative
portion there must be no reference to procedure-names that appear
in the declarative portion, except that PERFORM statements can
refer to a USE statement.
3. Within a USE procedure, there must be no execution of any
statement that would cause the execution of a USE procedure that
had previously been invoked and had not yet returned control to
the invoking routine.
Format 1 (Sequential, Relative and Indexed Files)
4. The designated procedures are executed by the input-output system
after completing the standard input-output error routine, or upon
recognition of the AT END condition, when the AT END phrase has not
been specified in the input-output statement.
________________________________________________________________________
|(ANS85) |
| |
| |
| |
|5. When file-name-1 is specified explicitly, no other USE statement |
| applies to file-name-1. |
| |
________________________________________________________________________
________________________________________________________________________
|(OSVS) (VSC2) |
| |
|Formats 2 and 3 (Record Sequential, Relative and Indexed Files) |
| |
| |
| |
|6. The LABEL PROCEDURE declarative is never executed unless by an |
| explicit PERFORM statement in the non-declarative portion of the |
| Procedure Division. |
| |
|7. The statement GO TO MORE-LABELS is treated as a simple |
| jump to the start of the declarative procedure in which it |
| appears. |
| |
________________________________________________________________________
The WRITE Statement
Function
The WRITE statement releases a logical record for an output or
input-output file. For sequential files it can also be used for vertical
positioning of lines within a logical page.
________________________________________________________________________
|(XOPEN) |
|Although they are a part of the standard COBOL definition, mnemonic |
|names in the ADVANCING phrase are explicitly excluded from the X/Open |
|COBOL language definitions and should not be used in X/Open COBOL |
|source programs. |
________________________________________________________________________
General Formats
Format 1 (Record and Line Sequential Files)
Format 4 (Relative and Indexed Files)
Syntax Rules
All Formats (All Files)
________________________________________________________________________
|(ANS85) |
| |
| |
| |
|1. If identifier-1 is a function-identifier, it must reference |
| an alpha-numeric function. When identifier-1 is not a |
| function-identifier, record-name and identifier-1 must not |
| reference the same storage area. |
| |
________________________________________________________________________
2. Record-name is the name of a logical record in the File Section of
the Data Division and can be qualified.
________________________________________________________________________
|(OSVS) (VSC2) (MF) |
| |
| |
| |
|3. Record-name can define a floating-point item. |
| |
|4. Identifier-1 can be defined as a floating-point item. |
| |
________________________________________________________________________
Format 1 (Record Sequential Files)
________________________________________________________________________
|(MF) |
| |
| |
| |
|5. When the mnemonic-name associated with TAB is specified the |
| result is to cause the paper to throw to the standard vertical |
| tabulation position. A user-defined mnemonic-name can be used |
| instead of TAB if it is associated in the SPECIAL-NAMES |
| paragraph. (See the section "The Special-Names Paragraph" in|
| the chapter The Nucleus.) |
| |
________________________________________________________________________
6. When identifier-2 is used in the ADVANCING phrase, it must be the
name of an elementary integer data item.
7. Integer, or the value of the data item referenced by identifier-2,
can be zero.
8. If the END-OF-PAGE phrase is specified, the linage clause must be
specified in the file description entry for the associated file.
9. The words END-OF-PAGE and EOP are equivalent.
10. The ADVANCING mnemonic-name phrase cannot be specified when writing
a record to a file whose file description entry contains the LINAGE
clause.
________________________________________________________________________
|(ANS85) |
| |
| |
| |
|11. The phrases ADVANCING PAGE and END-OF-PAGE must not both be |
| specified in a single WRITE statement. |
| |
________________________________________________________________________
________________________________________________________________________
|This restriction can be ignored. (MF) |
________________________________________________________________________
________________________________________________________________________
|(OSVS) (VSC2) (MF) |
|Alternatively, function-name can itself be used instead of an |
|associated mnemonic name |
________________________________________________________________________
Format 2 (Record Sequential Files)
________________________________________________________________________
|(OSVS) |
| |
| |
| |
|12. This format cannot be specified when writing a record to |
| a file whose file description entry contains the LINAGE |
| clause. |
| |
|13. If this format of the WRITE statement is used for writing to a |
| given file, then every WRITE statement used for that file should |
| be in this format. |
| |
|14. In the AFTER POSITIONING phrase, identifier-2 must be defined as |
| a single-character alphanumeric item. See General Rule 18 for |
| its possible values. |
| |
________________________________________________________________________
Format 4 (Relative And Indexed Files)
15. The INVALID KEY phrase must be specified if an applicable USE
procedure is not specified for the associated file.
________________________________________________________________________
|This rule is not enforced. (OSVS) (VSC2) (MF) |
________________________________________________________________________
General Rules
All Formats (All Files)
1. The results of the execution of the WRITE statement with the FROM
phrase is equivalent to the execution of:
a. The statement:
MOVE identifier-1 TO record-name
according to the rules specified for the MOVE statement,
followed by:
b. The same WRITE statement without the FROM phrase.
The contents of the record area prior to the execution of the
implicit MOVE statement have no effect on the execution of this
WRITE statement.
After execution of the WRITE statement is complete, the
information in the area referenced by identifier-1 is available,
even though the information in the area referenced by record-name
can not be. (See General Rule 13.)
2. The file position indicator is unaffected by the execution of a
WRITE statement.
3. The execution of the WRITE statement causes the value of the FILE
STATUS data item, if any, associated with the file to be updated.
(See the section "I/O Status" earlier in this chapter.)
4. The maximum record size for a file is established at the time the
file is created and must not subsequently be changed.
5. The number of character positions on a mass storage device to
store a logical record in a file may or may not be equal to the
number of character positions defined by the logical description
of that record in the program.
6. The execution of the WRITE statement releases a logical record to
the operating system.
________________________________________________________________________
|(ANS85) |
| |
| |
| |
|7. If the execution of the WRITE statement is unsuccessful, the I/O |
| status of the file-name associated with record-name is updated |
| and control is transferred according to the rules of the |
| USE statement following the execution of any USE AFTER |
| EXCEPTION procedure applicable to the file-name associated with |
| record-name. (See the section "The USE Statement" in this |
| chapter.) |
| |
________________________________________________________________________
Format 1 (Record Sequential Files)
8. If the logical end of the representation of the printed page is
reached during the execution of a WRITE statement with the
END-OF-PAGE phrase, the imperative-statement specified in the
END-OF-PAGE phrase is executed. The logical end is specified in the
LINAGE clause associated with record-name.
9. An end-of-page condition is reached whenever the execution of a
given WRITE statement with the END-OF-PAGE phrase occurs, when the
execution of such a WRITE statement causes the LINAGE-COUNTER to
equal or exceed the value specified by integer-2 or the data item
referenced by data-name-2 of the LINAGE clause, if specified. In
this case, the WRITE statement is executed and then the imperative
statement in the END-OF-PAGE phrase is executed.
An automatic page overflow condition is reached whenever the
execution of a given WRITE statement (with or without an END-OF-PAGE
phrase) cannot be fully accommodated within the current page body.
This occurs when a WRITE statement, if executed, would cause the
LINAGE-COUNTER to exceed the value specified by integer-1 or the
data item referenced by data-name-1 of the LINAGE clause. In this
case, the record is presented on the logical page before or after
(depending on the phrase used) the device is repositioned to the
first line that can be written on the next logical page as specified
in the LINAGE clause. The imperative statement in the END-OF-PAGE
clause, if specified, is executed after the record is written and
the device has been repositioned.
If integer-2 or data-name-2 of the LINAGE clause is not specified,
no end-of-page condition distinct from the page overflow condition
is detected. In this case, the end-of-page condition and page
overflow condition occur simultaneously.
If integer-2 or data-name-2 of the LINAGE clause is specified, but
the execution of a given WRITE statement would cause LINAGE-COUNTER
to simultaneously exceed the value of both integer-2 or the data
item referenced by data-name-2 and integer-1 or the data item
referenced by data-name-1, then the operation proceeds as if
integer-2 or data-name-2 had not been specified.
________________________________________________________________________
|(MF) |
| |
|Format 1 (Line Sequential Files) |
| |
| |
| |
|10. If the ADVANCING phrase is not used, automatic advancing of one |
| line is provided to act in accordance with the convention of your|
| operating system text editor (usually as if you had specified |
| BEFORE ADVANCING 1 LINE). |
| |
|11. When an attempt is made to write beyond the externally defined |
| boundaries of a sequential file, an exception condition exists |
| and the contents of the record area are unaffected. The |
| following actions take place: |
| |
| |
| a. The value of the FILE STATUS data item, if any, of the |
| associated file is set to a value indicating a boundary |
| violation. (See the section I/O Status in this |
| chapter.) |
| |
| b. If a USE AFTER STANDARD EXCEPTION declarative is |
| explicitly or implicitly specified for the file, that |
| declarative procedure will be executed. |
| |
| c. If a USE AFTER STANDARD EXCEPTION declarative is not |
| explicitly or implicitly specified for the file, the |
| result will be undefined. |
| |
|12. After the recognition of an end-of-unit of an output file that is|
| contained on more than one physical reel/unit, the WRITE |
| statement performs the following operations: |
| |
| |
| a. The standard ending reel/unit procedure. |
| |
| b. The reel/unit swap. |
| |
| c. the standard beginning of reel/unit label procedure. |
| |
|13. If, during the successful execution of a WRITE statement with the|
| NOT END-OF-PAGE phrase, the end-of-page condition does not occur,|
| control is transferred to imperative-statement-2 after execution |
| of the input-ouput operation. (ANS85) |
| |
________________________________________________________________________
Format 1 (Record and Line Sequential Files)
14. Both the ADVANCING phrase and the END-OF-PAGE phrase allow control
of the vertical positioning of each line on a representation of a
printed page.
If the ADVANCING phrase is not used, automatic advancing is provided
when output is directed to a list-device (PRINTER or PRINTER-1: see
the section Line Advancing earlier in this chapter), to act as if
the user had specified AFTER ADVANCING 1 LINE. If the ADVANCING
phrase is used, advancing is provided as follows:
a. If identifier-2 is specified, the representation of the
printed page is advanced the number of lines equal to the
current value associated with identifier-2.
b. If integer is specified, the representation of the printed
page is advanced in the number of lines equal to the value of
integer.
c. If mnemonic-name is specified, the representation of the
printed page is advanced as specified under the "The
Special-Names Paragraph" paragraph in the chapter The
Nucleus.
d. If the BEFORE phrase is used, the line is presented before
the representation of the printed page is advanced according
to rules a, b, and c above.
e. If the AFTER phrase is used, the line is presented after the
representation of the printed page is advanced according to
rules a, b, and c above.
f. If PAGE is specified, the record is presented on the logical
page before or after (depending on the phrase used) the
device is repositioned to the next logical page. If the
record to be written is associated with a record sequential
file whose file description entry contains a LINAGE clause,
the device is repositioned to the first line that can be
written on the next logical page as specified in the LINAGE
clause.
15. The phrases ADVANCING PAGE and END-OF-PAGE must not both be
specified in a single WRITE statement.
Formats 1, 2, and 3 (Sequential Files)
16. The associated file must be open in the OUTPUT or EXTEND mode at the
time of the execution of this statement. (See the section "The OPEN
Statement" in this chapter.)
17. The logical record released by the execution of the WRITE statement
is no longer available in the record area unless the associated file
is named in a SAME RECORD AREA clause or the execution of the WRITE
statement was unsuccessful due to a boundary violation.
The logical record is also available to the program as a record of
other files referenced in the SAME RECORD AREA clause as the
associated output file, as well as to the file associated with
record-name.
Format 2 (Record Sequential Files)
________________________________________________________________________
|(OSVS) |
| |
| |
| |
|18. When the AFTER POSITIONING phrase is used in a WRITE statement, |
| the system will move a suitable character into the first |
| position of the record before it is written to the file. |
| This first character position must be reserved by the user |
| for this purpose. If the identifier-2 option is used, |
| then the character moved into the output record is simply |
| the value held by identifier-2 and should be one of the |
| following: |
| |
| |
| Identifier-2 Interpretation |
| |
| (space) Single-spacing |
| 0 Double-spacing |
| - Triple-spacing |
| + Suppress spacing |
| 1-9 Skip to channel 1-9, respectively |
| A, B, C Skip to channel 10, 11, 12, respectively |
| V, W Pocket select 1 or 2 |
| |
| |
| If the integer-1 option is used, then the character placed in the|
| output record is determined as follows: |
| |
| |
|Integer Output Character Interpretation |
| |
|0 1 Skip to channel 1 |
|1 (space) Single-space |
|2 0 Double-spacing |
|3 - Triple-spacing |
| |
| |
| The implicit move will always take place according to the above |
| rules, but actions based on the given interpretations are |
| system-dependent (see your Release Notes). |
| |
|19. The END-OF-PAGE phrase, if specified, is documentary and as such |
| is never executed. |
| |
________________________________________________________________________
________________________________________________________________________
|(OSVS) (VSC2) (MF) |
| |
|Format 3 (Record Sequential Files) |
| |
| |
| |
|20. When an attempt is made to write beyond the externally defined |
| boundaries of a sequential file, an INVALID KEY condition occurs.|
| When the INVALID KEY condition is recognized by the COBOL system,|
| the execution of the WRITE statement is unsuccessful; the |
| contents of the record area are unaffected, and the FILE STATUS |
| data item, if any, of the associated file is set to a value |
| indicating the cause of the condition. Execution of the program |
| proceeds according to the rules stated in The INVALID KEY |
| Condition in this chapter (see also the section "I/O Status" |
| in this chapter). |
| |
________________________________________________________________________
Format 4 (Relative and Indexed Files)
21. The associated file must be open in the OUTPUT, I/O or EXTEND mode
at the time of execution of this statement; an indexed file must not
be open in the I/O mode with sequential access mode. (See the
sections "The FILE-CONTROL Entry" and "The OPEN Statement"
in this chapter.)
22. The logical record released by the execution of the WRITE statement
is available in the record area only if the associated file is named
in a SAME RECORD AREA clause, or the execution of the WRITE
statement is unsuccessful due to an INVALID KEY condition.
The logical record is also available to the program as a record of
other files referenced in the same SAME RECORD AREA clause as the
associated output file, as well as to the file associated with
record-name.
23. When the INVALID KEY condition is recognized, the execution of the
WRITE statement is unsuccessful; the contents of the record area are
unaffected, and the FILE STATUS data item, if any, of the associated
file is set to a value indicating the cause of the condition.
Execution of the program proceeds according to the rules stated in
The INVALID KEY Condition in this chapter (see also the section "I/O
Status" in this chapter).
________________________________________________________________________
|(MF) |
| |
| |
| |
|24. If the file has multiple record locking, the WRITE statement can |
| be made to acquire a record lock by use of the WRITELOCK |
| directive. See your COBOL System Reference for details of this |
| directive. |
| |
________________________________________________________________________
Format 4 (Relative Files)
25. When a file is opened in the output mode, records can be placed into
the file by one of the following:
a. If access mode is sequential, the WRITE statement will cause
a record to be released to the operating system. The first
record will have a relative record number of one and
subsequent records released will have relative record numbers
of 2, 3, 4, ... . If the RELATIVE KEY data item has been
specified in the file control entry for the associated file,
the relative record number of the record just released will
be placed into the RELATIVE KEY data item by the operating
system during execution of the WRITE statement.
b. If access mode is random or dynamic, the value of the
RELATIVE KEY data item must be initialized in the program,
prior to the execution of the WRITE statement, with the
relative record number, or be associated with the record in
the record area. That record is then released to the
operating system by execution of the WRITE statement.
26. When a file is opened in I/O mode and access mode is random or
dynamic, the value of the RELATIVE KEY data item must be initialized
by the program with the relative record number to be associated with
the record in the record area. Execution of a WRITE statement then
causes the contents of the record area to be released to the
operating system.
27. The INVALID KEY condition exists under the following circumstances:
a. When access mode is random or dynamic, and the RELATIVE KEY
data item specifies a record which already exists in the
file, or:
b. When an attempt is made to write beyond the externally
defined boundaries of the file.
Format 4 (Indexed Files)
28. Execution of the WRITE statement causes the contents of the record
area to be released. The operating system uses the contents of the
record keys so that subsequent access of the record can be made via
any of those specified record keys.
29. The value of the prime record key should be unique within the
records in the file.
30. The data item specified as the prime record key must be set by the
program to the desired value prior to the execution of the WRITE
statement.
31. If sequential access mode is specified for the file, records must be
released to the operating system in ascending order of prime record
key values.
32. If random or dynamic access mode is specified, records can be
released to the operating system in any program-specified order.
33. When the ALTERNATE RECORD KEY clause is specified in the file
control entry for an indexed file, the value of the alternate record
key can be non-unique only if the DUPLICATES phrase is specified for
that data item. In this case, the operating system provides storage
of records so that when records are accessed sequentially, those
records are retrieved in the order in which they are released to the
operating system.
34. The INVALID KEY condition exists under the following circumstances:
a. When sequential access mode is specified for a file opened in
output mode, and the value of the prime record key is not
greater than the value of the prime record key of the
previous record, or:
b. When the file is opened in output or I/O mode, and the value
of the prime record key is equal to the value of a prime
record key of a record already existing in the file, or:
c. When the file is opened in output or I/O mode, and the value
of an alternate record key for which duplicates are not
allowed equals the corresponding data item of a record
already existing in the file, or:
d. When an attempt is made to write beyond the externally
defined boundaries of the file.
________________________________________________________________________
|(ANS85) |
| |
| |
| |
|35. Transfer of control following the successful or unsuccessful |
| execution of the WRITE operation depends on the presence or |
| absence of the INVALID KEY and NOT INVALID KEY phrases. |
| (See the section "The INVALID KEY Condition" in this |
| chapter.) |
| |
________________________________________________________________________
MPE/iX 5.0 Documentation