COBOL Manual for TNS/E Programs (H06.03+)

Procedure Division Verbs
HP COBOL Manual for TNS/E Programs520347-003
9-44
DELETE
In a Pathway environment under the NonStop Transaction Management Facility
(TMF), the last operation on the file must have been a successful execution of a
READ LOCK statement (rather than a READ statement). For information on coding
servers, see the Pathway/TS SCREEN COBOL Reference Manual for your
system.
The record retrieved by the READ statement is deleted.
Record Deleted When File Access Mode is Random or Dynamic
If the file’s access mode is random or dynamic, the record to be deleted is defined
by the record key, or, for relative files, the relative key (indexed or prime key). If the
designated record does not exist, an invalid-key condition occurs with I-O status
code “23.”
Example 9-12. DELETE Statement
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPLOYEE-MASTER ASSIGN TO "EMPMAST"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS EMPLOYEE-NUMBER
FILE STATUS IS FILE-STAT.
...
FD EMPLOYEE-MASTER
LABEL RECORDS ARE OMITTED
...
05 EMPLOYEE-NUMBER PIC X(7).
...
PROCEDURE DIVISION.
...
DELETE-RECORD.
MOVE KEY-TO-DELETE TO EMPLOYEE-NUMBER
DELETE EMPLOYEE-MASTER RECORD
INVALID KEY PERFORM KEY-ERROR
END-DELETE