10.7 REWRITE Statement

The REWRITE statement is a data transfer output statement that rewrites the current record.

A REWRITE statement can be formatted or unformatted, and takes one of the following forms:


REWRITE (eunit, format [, iostat] [, err]) [io-list]


REWRITE (eunit [, iostat] [, err]) [io-list]

Is an external unit specifier ([UNIT=]io-unit).

Is a format specifier ([FMT=]format).

Is a status specifier (IOSTAT=i-var).

Is a branch specifier (ERR=label) if an error condition occurs.

Is an I/O list.

In the REWRITE statement, data (translated if formatted; untranslated if unformatted) is written to the current (existing) record in one of the following types of external files:

The current record is the last record accessed by a preceding, successful sequential, indexed (VMS only), or direct-access READ statement.

Between a READ and REWRITE statement, you should not specify any other I/O statement (except INQUIRE) on that logical unit. Execution of any other I/O statement on the logical unit destroys the current-record context and causes the current record to become undefined.

Only one record can be rewritten in a single REWRITE statement operation.

The output list (and format specification, if any) must not specify more characters for a record than the record size. (Record size is specified by RECL in an OPEN statement.)

If the number of characters specified by the I/O list (and format, if any) do not fill a record, blank characters are added to fill the record.

If the primary key (VMS only) value is changed in a keyed-access file, an error occurs.


In the following example, the current record (contained in the relative organization file connected to logical unit 3) is updated with the values represented by NAME, AGE, and BIRTH:

      REWRITE (3, 10, ERR=99) NAME, AGE, BIRTH
10    FORMAT (A16, I2, A8)

For More Information:

Previous Page Next Page Table of Contents