Deleting Relative Records In Random Access Mode - Compaq COBOL AAQ2G1FTK User Manual

Compaq computer accessories user manual
Table of Contents

Advertisement

Processing Files and Records
6.5 Updating Files
Example 6–40 (Cont.) Deleting Relative Records in Sequential Access Mode
DATA DIVISION.
FILE SECTION.
FD FLAVORS.
01 KETCHUP-MASTER
WORKING-STORAGE SECTION.
01 KETCHUP-MASTER-KEY
PROCEDURE DIVISION.
A000-BEGIN.
OPEN I-O FLAVORS.
PERFORM A010-DELETE-RECORDS UNTIL KETCHUP-MASTER-KEY = 00.
A005-EOJ.
DISPLAY "END OF JOB".
CLOSE FLAVORS.
STOP RUN.
A010-DELETE-RECORDS.
DISPLAY "TO DELETE A RECORD ENTER ITS RECORD NUMBER".
ACCEPT KETCHUP-MASTER-KEY.
IF KETCHUP-MASTER-KEY NOT = 00 PERFORM A200-READ-FLAVORS
A200-READ-FLAVORS.
START FLAVORS
READ FLAVORS AT END DISPLAY "FILE AT END"

Deleting Relative Records in Random Access Mode

Deleting a relative record in random access mode involves the following:
1. Specifing ORGANIZATION IS RELATIVE in the Environment Division
SELECT clause
2. Specifying ACCESS MODE IS RANDOM in the Environment Division
SELECT clause
3. Opening the file for I-O
4. Moving the relative record number value to the RELATIVE KEY data name
5. Deleting the record identified by the relative record number
If the file does not contain a valid record, an invalid key condition exists.
Example 6–41 deletes relative records in random access mode.
Example 6–41 Deleting Relative Records in Random Access Mode
IDENTIFICATION DIVISION.
PROGRAM-ID. REL10.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT FLAVORS ASSIGN TO "BRAND"
ACCESS MODE IS SEQUENTIAL
RELATIVE KEY IS KETCHUP-MASTER-KEY.
PIC X(50).
PIC 99 VALUE 1.
INVALID KEY DISPLAY "INVALID START"
STOP RUN.
GO TO A005-EOJ.
ORGANIZATION IS RELATIVE
DELETE FLAVORS RECORD.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COBOL AAQ2G1FTK and is the answer not in the manual?

Table of Contents