COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-203
REWRITE for Sequential, Relative, Indexed, and
Queue Files
record-name
is the record-name in a file description entry whose current contents replaces a
record in the file. The file must be open in I-O mode.
data-name
is the identifier of the item that contains the new record instead of record-name.
When this phrase is used, an implicit MOVE statement occurs to copy the data to
record-name before the rewrite operation occurs. data-name cannot specify
an index-name or an index data item. data-name cannot specify a data item
allocated within the record area in which record-name is located.
UNLOCK
permits access by other processes to a record (after the rewrite operation) that was
previously locked with a LOCK phrase.
imperative-stmt-1
is an imperative statement to be performed when an invalid-key condition is
encountered by the REWRITE operation. It is required if no USE statement is
applicable for the file. If both a USE statement and an INVALID KEY phrase are
present, only the INVALID KEY phrase is used.
imperative-stmt-2
is an imperative statement to be performed when no invalid-key condition is
encountered by the REWRITE operation.
END-REWRITE
ends the scope of the REWRITE statement, causing the REWRITE to be a
delimited-scope statement. If the REWRITE statement does not end with an END-
REWRITE phrase, the presence of the INVALID KEY or the NOT INVALID KEY
phrase causes the REWRITE statement to be a conditional statement, which ends
at the next period separator.
Usage Considerations:
•
Action of the REWRITE Statement
The rewrite operation releases a logical record to the run-time routines as a
replacement for a record that exists in the file. The size of the logical record (the
number of character positions in the record) is determined:
°
When the file has fixed length records (the file description entry includes a
RECORD CONTAINS n CHARACTERS, or contains no RECORD clause at
all), the size of the logical record is the fixed record size.