ERASE Statement

The ERASE statement removes all records from a file, leaving the attributes of the file unchanged where possible. The LASTRECORD attribute is set to –1 and all data are lost. For more information on file attributes, see the File Attributes Programming Reference Manual.

<erase statement>

── ERASE ── ( ──<file designator>── ) ─────────────────────────────────┤

The ERASE statement can be used as a Boolean primary. When it is used in this way, it returns one of the following enumerated results if an error has occurred:

NOTCLOSERETAINED
VALIDONLYFORDISK
NODISKHEADER
SECURITYERROR
NOTONLYUSEROFFILE

In using the ERASE statement, the following requirements must be met:

  • The file specified in the ERASE statement must be a local file and the KIND attribute must be disk or pack.

  • The file must be closed with retention.

  • The open count of the file must be 1.

  • The user must have access to the file.

The user process is discontinued if an error occurs when the ERASE statement is not used as a Boolean primary.