The ERASE statement deletes a logical-record occurrence. The ERASE statement does not necessarily result in the deletion of all or any of the database records used to create the specified logical record. The path selected to service an ERASE logical-record request performs whatever database access operations the DBA has specified to service the request. For example, if a DEPARTMENT loses an employee, the EMP_JOB_LR logical record that contains information about that employee would be erased. However, only the information about the former employee would be erased from the database, not all the information about the department; that is, EMPLOYEE information would be erased, but not DEPARTMENT, JOB, or OFFICE information.
LRF uses field values present in the variable-storage location reserved for the logical record to update the database. You can specify an alternative storage location from which LRF is to take field values to make the appropriate updates to the database.
►►─── ERASE RECORD (logical-record-name) ─────────────────────────────────────► ►─┬─────────────────────────────┬─┬──────────────────────────────┬───────────► └─ FROM (alt-logical-record) ─┘ └─ WHERE (boolean-expression) ─┘ ►─┬────────────────────────────────────────────────────┬─ ; ─────────────────►◄ └─ ON LR_STATUS (path-status) imperative-statement ─┘
Names the logical record to be deleted. Unless the FROM clause (see below) is included, LRF uses field values present in the variable-storage location reserved for the logical record to make any necessary updates to the database. Logical-record-name must specify a logical record defined in the subschema.
Names an alternative variable-storage location from which LRF is to obtain field values to perform the appropriate database updates in response to this request. When erasing a logical record that has been previously retrieved into an alternative storage location, use the FROM clause to name the same location specified in the OBTAIN request. If the FROM clause is included in the ERASE statement, alt-logical-record must identify a record location defined in program variable storage.
Specifies the selection criteria to be applied to the specified logical record. For details on coding this clause, see Logical-Record Clauses (WHERE and ON) at the end of this chapter.
Specifies the action to be taken if path-status is returned to the LR_STATUS field in the LRC block. Path-status must be a 1- to 16-character alphanumeric value. For details on coding this clause, see Logical-Record Clauses (WHERE and ON) at the end of this chapter.
The following example illustrates a request to erase all occurrences of a former employee's EMP_INSURANCE_LR logical record. The DBA-designated path status ALL_ERASED indicates that all occurrences of the EMP_INSURANCE_LR logical record have been erased.
ERASE RECORD (EMP_INSURANCE_LR) WHERE (EMP_ID_0415 EQ '0316') ON LR_STATUS (ALL_ERASED) CALL EMP_INS_DELETION_RPT;
D, M, and F under Coverage in the following figure are physically erased from the database as a result of the ERASE RECORD (EMP_INSURANCE_LR) statement. As defined by the DBA, the ERASE EMP_INSURANCE_LR path group logically deletes all of the specified EMP_INSURANCE_LR occurrences, but physically deletes only the D, M, and F COVERAGE records.

|
Copyright © 2014 CA.
All rights reserved.
|
|