── REMOVE ─┬─────────────────────┬─────────────────────────────────────► └─ [ ── DESTROY ── ] ─┘ ►─┬─ <remove list> ──────────────────────────────────┬─────────────────► │ ┌◄────────── , ─────────┐ │ └─┴─ <remove from group> ─┴─┬──────────────────────│ └─ , ── <remove list> ─┘ ►─┬────────────────────────────────────────────────────────────────┬───┤ └─ [ ──<b1>─┬──────────────────────────────────────────────┬─ ] ─┘ └─ , ──<i>─┬───────────────────────────────────┤ └─ , ──<b2>─┬───────────────────────┤ └─ , ──<b3>─┬───────────┤ └─ , ──<b4>─┘
┌◄───────────── , ─────────────┐ ──┴─┬─ <long file title> ──────┬─┴─────────────────────────────────────┤ └─ <long directory title> ─┘
┌◄───────────── , ────────────┐ ──┴─┬─ <long file name> ──────┬─┴─ FROM ── <family name> ──────────────┤ └─ <long directory name> ─┘
Explanation
The REMOVE statement removes files from disk and marks the archive backup records (if there are any) indicating that the files are “removed.” The removed files cannot be restored by the archive AUTORESTORE feature, but they can be restored by using the WFL “ARCHIVE RESTORE” and “ARCHIVE ADDRESTORE” statements. For information regarding how to remove and restore files using the archive AUTORESTORE feature, refer to ARCHIVE RELEASE Statement earlier this section.
The DESTROY option causes all catalog and archive directory records for the file(s) to be purged. In addition, the catalog and archive records will be purged for named files and directories even if the files are not resident. The REMOVE DESTROY statement is equivalent to a REMOVE statement followed by a CATALOG PURGE statement followed by an ARCHIVE PURGE statement. Files that are removed with the DESTROY option cannot be restored with the WFL statement ARCHIVE RESTORE.
If a directory is specified, all files in that directory are removed. The directories *= and = cannot be used in the REMOVE statement.
If the REMOVE command is used to remove a file whose LOCKEDFILE file attribute is set to TRUE, that file is not deleted. The system displays the following message to indicate that the file was not removed:
<file name> NOT REMOVED (LOCKEDFILE).
See the ALTER statement in this section for more information about changing the LOCKEDFILE file attribute. For more information about the LOCKEDFILE file attribute, refer to the File Attributes Programming Reference Manual.
The first name in a remove list can be a file title or directory title; that is, it can contain an ON family name part. Subsequent names in the remove list can only contain an ON family name part if they contain a string primary as well.
In the remove from group, the FROM clause applies to all the file names and directory names in that remove from group.
Family substitution is used if the job or task has an active family specification. Only the primary family name is used. Refer to FAMILY Assignment and Interrogating Complex Task Attributes.
Path substitution is used if the job has an active DATAPATH attribute specification. Only the first path element is used. For more information on active DATAPATH attribute specification, refer to DATAPATH Assignment and Interrogating Complex Task Attributes.
Remove Results
The REMOVE statement can be followed by an optional results structure: [b1, i, b2, b3, b4]. Parameters are optional. For example [b1, i] is syntactically correct. However, if a parameter is specified, all preceding parameters must also be specified. The parameters return the following information:
Variable |
Type |
Description |
---|---|---|
b1 |
Boolean |
TRUE if a failure occurred. FALSE if all files and directories were removed. |
i |
Integer |
Total number of removed files |
b2 |
Boolean |
TRUE if at least one file or directory was not removed because it was not present. |
b3 |
Boolean |
TRUE if at least one file was not removed because the file was a locked file. |
b4 |
Boolean |
TRUE if at least one file was not removed because of a security error. |
Examples
The following examples illustrate the REMOVE statement syntax.
This statement removes the file X from DISK:
REMOVE X;
This statement removes the file A/B from USERS:
REMOVE A/B ON USERS;
These statements remove all the files under the directory A/= from USERS, and remove all the files under the directory B/= from PACK:
S1:="A/= ON USERS"; S2:="B/= ON PACK"; REMOVE #S1, #S2;
These statements remove the file X from DISK, and remove all the files under the directory Y/= from PACK:
S:="Y/="; REMOVE X, #S ON PACK;
These statements remove the file X from DISK, the file Y from MYPACK, the file X/Y from PACK, and the file Z from DISK:
S:="Y"; REMOVE X, #S FROM MYPACK, X/Y FROM PACK, Z;
This job demonstrates the use of the optional results:
BEGIN JOB DEMONSTRATE/REMOVE; BOOLEAN BFAILED, BMISSING, BLOCKED, BSEC; INTEGER COUNT; REMOVE CHANGETEST3/=, CHANGETEST2/=, CHANGETEST7 [BFAILED, COUNT, BMISSING, BLOCKED, BSEC]; DISPLAY "Remove test: " & STRING (COUNT, *) & " files removed"; IF NOT BFAILED THEN DISPLAY "All files removed"; IF BMISSING THEN DISPLAY "Missing files"; IF BLOCKED THEN DISPLAY "Locked files seen"; IF BSEC THEN DISPLAY "Security error seen"; REMOVE CHANGETEST3/=, CHANGETEST2/=, CHANGETEST7 [BFAILED, COUNT]; % Not all variables are needed DISPLAY "Remove test: " & STRING (COUNT, *) & " files removed"; IF NOT BFAILED THEN DISPLAY "All files removed"; END JOB