Previous Topic: STORE RECORDNext Topic: TRANSFER (DC/UCF)


STORE RECORD (LRF)

The STORE RECORD statement updates the database with field values for a logical-record occurrence. STORE RECORD does not necessarily result in storing new occurrences of all or any of the database records that participate in the logical record; the path selected to service a STORE RECORD logical-record request performs whatever database access operations the DBA has specified to service the request. For Example, if an existing department gets a new employee, only the new employee information will be stored in the database; the department information need not be stored in the database because it already exists.

LRF uses field values present in the variable-storage location reserved for the logical record to make the appropriate updates to the database. You can optionally name an alternative storage location from which the new field values are to be obtained to perform the requested store operation.

Syntax
►►─── STORE RECORD (logical-record-location) ─────────────────────────────────►

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

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

Names the logical record to be stored. Unless the FROM clause (see below) is included, LRF uses field values present in the variable-storage location reserved for the specified logical record to make the appropriate updates to the database. Logical-record-name must specify a logical record defined in the subschema.

FROM (alt-logical-record-location)

Names an alternative variable storage location that contains the field values to be used to make appropriate updates to the database. When storing a logical record that has previously been retrieved into an alternative variable storage location, use the FROM clause to name the same area specified in the OBTAIN request. If the FROM clause is included in the STORE RECORD statement, alt-logical-record-location must identify a record location defined in program variable storage.

WHERE (boolean expression)

Specifies selection criteria to be applied to the object 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 necessary to store a new logical record, EMP-INSURANCE-LR, for a given employee:

EMP_ID_0415 = EMP_ID_IN;
INS_PLAN_CODE_0435 = INS_PLAN_IN;
SELECTION_DATE_0400 = S_DATE_IN;
TERMINATION_DATE_0400 = T_DATE_IN;
TYPE_0400 = TYPE_IN;
INS_PLAN_CODE_0400 = PLAN_IN;
STORE RECORD (EMP_INSURANCE_LR);

The following figure illustrates the new occurrence of the record EMP_INSURANCE_LR. The new occurrence of EMP_INSURANCE_LR consists of EMPLOYEE 149, INS_PLAN 001, and COVERAGE 'D'. The COVERAGE occurrence represents the only data physically added to the database.