Previous Topic: MODIFY RECORDNext Topic: OBTAIN (LRF)


MODIFY RECORD (LRF)

The MODIFY RECORD statement changes field values in an existing logical-record occurrence. LRF uses the field values present in the variable-storage location reserved for the logical record to update the appropriate database records. You can optionally specify an alternative variable storage location from which the changed field values are to be obtained.

Syntax
►►─── MODIFY RECORD (logical-record-name) ────────────────────────────────────►

 ►─┬──────────────────────────────────────┬─┬──────────────────────────────┬──►
   └─ FROM (alt-logical-record-location) ─┘ └─ WHERE (boolean-expression) ─┘

 ►─┬────────────────────────────────────────────────────┬─ ; ─────────────────►◄
   └─ ON LR_STATUS (path-status)  imperative-statement ─┘
Parameters
logical-record-name

Defines the named logical-record occurrence, as specified in program variable storage. Unless the FROM clause is specified (see below), the field values used to update the database are taken from the area in program variable storage reserved for the named logical record. Logical-record-name must specify a logical record defined in the subschema.

FROM (alt-logical-record-location)

Names an alternative variable-storage location from which the field values used to perform the requested modification are to be obtained. When modifying a logical record that was retrieved into an alternative location in variable storage, the FROM clause should name the same location specified in the OBTAIN request. If the FROM clause is included in the MODIFY RECORD statement, alt-logical-record-location must identify a record location defined in program variable storage.

WHERE boolean-expression

Specifies the selection criteria to be applied to the named logical record. For details on coding the WHERE clause, see Logical-Record Clauses (WHERE and ON) at the end of this chapter.

ON LR_STATUS (path-status) imperative-statement

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.

Example

The following Example illustrates the steps taken to modify an occurrence of the EMP_SKILL_LR logical record. Assume that the skill level for employee 120 is to be upgraded from 02 (COMPETENT_0425) to 03 (PROFICIENT_0425).

  1. Retrieve the desired logical-record occurrence:
    OBTAIN FIRST RECORD (EMP_SKILL_LR)
      WHERE (EMP_ID_0415 = '0120'
       AND SKILL_ID_0455 = '3610'
       AND SKILL_LEVEL_0425 = '02');
    
  2. Update the SKILL_LEVEL_0425 field:
    SKILL_LEVEL_0425 = '03';
    
  3. Issue the MODIFY RECORD (LRF) statement for the updated EMP_SKILL_LR logical record:
    MODIFY RECORD (EMP_SKILL_LR);
    

LRF retrieves the EMP_SKILL_LR logical record where EMP_ID_0415 = '0120', SKILL_ID_0455 = '3610', and SKILL_LEVEL_0425 = '02'. The EXPERTISE occurrence represents the only data physically modified in the database.

EMP_SKILL_LR

EMPLOYEE    EXPERTISE    SKILL
120       04       7620
120       03       3710
120       02 (now 03)   3610