skip to main content

Procedure Division Statements : REWRITE

REWRITE
General Format
REWRITE Record-Name RECORD [ FROM Identifier-1 ]
  [ WITH [NOLOCK ] 
  [ INVALID KEY Imperative-Statement-1 ] 
  [ NOT INVALID KEY Imperative-Statement-2 ] 
  [END-REWRITE]
Syntax Rules
1.
2.
3.
4.
5.
General Rules
1.
2.
3.
4.
 
NOTE - Logical records in relative and sequential files may have a length of zero. Logical records in an indexed file shall always be long enough to contain the record keys.
5.
A.
 
MOVE identifier-1 TO record-name-1
 
or
 
MOVE literal-1 TO record-name-1
 
according to the rules specified for the MOVE statement.
B.
6.
7.
A.
i.
ii.
B.
C.
8.
9.
10.
11.
Sequential Files
12.
Relative and Indexed Files
13.
14.
15.
Relative Files
16.
Indexed Files
17.
18.
A.
B.
19.
A.
B.
 
When the invalid key condition is recognized, the execution of the REWRITE statement is unsuccessful, the updating operation does not take place, and the content of the record area is unaffected.
 
Examples
Update last read record validating the key
move 1234 to cust-code
read customers
add ws-invoice-amount to cust-total-debt
rewrite customer-record
 invalid key display message "Customer could not be updated. Code : " cust-code
 not invalid key display message "Customer updated. Code : " cust-code

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left