5 updating files – Compaq COBOL AAQ2G1FTK User Manual

Page 228

Advertising
background image

Processing Files and Records
6.4 Reading Files

Table 6–7 (Cont.) Indexed File—ISAM Mapping

COBOL Data Type

Maps To

Transformation Method

signed quadword
PIC S9(18) COMP

CHARTYPE

Reverse the bytes (integers: most
significant byte (msb) last; character
strings: msb first).

If the data type is not _UNSIGNED, then
complement the sign bit. This causes
negative values to sort correctly with
respect to each other, and precede positive
values.

unsigned quadword
PIC 9(18) COMP

CHARTYPE

Same as signed quadword.

packed decimal
PIC S9(n) COMP-3

CHARTYPE

(Note that sign nibble after is the only case
allowed in COBOL.) If the sign nibble is
minus, complement all bits. This will give
a sign nibble of 1 for a minus, which will
come before the plus.

Copy the nibbles so the sign nibble is
placed on the left and all the other nibbles
are shifted one to the right.

Note that any data type not directly supported by ISAM is translated to a
character string, which will sort as a character string in the correct order.

6.5 Updating Files

Updating sequential, line sequential, relative, and indexed files includes the
following tasks:

1.

Opening the file

2.

Executing a READ or START statement

3.

Executing a REWRITE and a DELETE statement

Sections 6.5.1, 6.5.2, and 6.5.3 describe how to update sequential, relative, and
indexed files.

6.5.1 Updating a Sequential or Line Sequential File

Updating a record in a sequential file involves the following:

1.

Opening the file for I/O

2.

Reading the target record

3.

Rewriting the target record

The REWRITE statement places the record just read back into the file. The
REWRITE statement completely replaces the contents of the target record with
new data. You can use the REWRITE statement for files on mass storage devices
only (for example, disk units). There are two ways of rewriting records:

REWRITE record-name FROM source-area

REWRITE record-name

6–48 Processing Files and Records

Advertising