Previous Topic: @STORENext Topic: #STRTPAG


@STORE (LRF)

The @STORE statement can also update the database with field values for new logical record occurrences. The @STORE statement does not necessarily store new occurrences of all or any of the database records that participate in the logical record; the path selected to service an @STORE logical-record request performs whatever database access operations the DBA has specified to service the request.

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

Syntax

►►─── @STORE REC=logical-record-name ─────────────────────────────────────────►

 ►─┬─────────────────────────────────────────────┬────────────────────────────►
   └─ ,IOAREA=alt-logical-record-location ───────┘

 ►─┬─────────────────────────────────────────────┬────────────────────────────►
   └─ ,ONLRSTS=path-status,GOTO=branch-location ─┘

 ►─┬─────────────────────────────┬────────────────────────────────────────────►◄
   └─ ,WHERE boolean-expression ─┘

Parameters

REC=logical-record-name

Names a new occurrence of the named logical record. Unless the IOAREA parameter (see below) is included, LRF updates the database by using field values stored in a variable-storage location reserved for the named logical record. Logical-record-name must specify a logical record defined in the subschema.

IOAREA=alt-logical-record-location

Identifies an alternative variable-storage location that contains the field values to be used to update the database. When storing a logical record that has previously been retrieved into an alternative variable-storage location, you should use the IOAREA clause to name the same area specified in the @OBTAIN request. If the IOAREA clause is included in the @STORE statement, alt-logical-record-location must identify a record location defined in the program.

ONLRSTS=path-status,GOTO=branch-location

Tests for the indicated path status. Path-status must be a quoted literal (1 to 16) or a program variable. If path-status results from this @STORE statement, the action specified by branch-location is performed. For more information about how to code the ONLRSTS clause, see the discussion of the ON clause later in this chapter.

WHERE boolean-expression

Specifies selection criteria to be applied to the named logical record. For details on how to code the WHERE clause, refer to the discussion of the WHERE clause later in this chapter.

Example

The example below illustrates how to add a new office by adding occurrences of the OFFEMPLR logical record. The program subsequently stores one occurrence of the OFFEMPLR logical record for each employee added to the office.

STOROFF  EQU   *
         MVC   OFFICE,NEWOFF
         @STORE REC=OFFEMPLR,WHERE ADD-OFFICE
         .
         .
STOREMP  EQU   *
         MVC   EMPL,NEWEMP
         @STORE REC=OFFEMPLR,WHERE ADD-EMP
         .
         .
         B     STOREMP

In the above example, the DBA has designated the keywords ADD-OFFICE and ADD-EMP to direct the request to a path designed to store new employee information for a new office. The path to which the first request is directed stores the appropriate new office information before storing the new employee information.

All input data concerning the new employee is contained in group fields called NEWOFF and NEWEMP, whose layouts correspond to those of the OFFICE and EMPLOYEE positions, respectively, of the OFFEMPLR logical record. The program moves the input field NEWOFF to the logical-record group field OFFICE and the input field NEWEMP to the logical-record group field EMPL.

Status Codes

After you issued an @STORE statement for a logical record, the type of status code returned to the program in the ERRSTAT field of the IDMS communications block depends on the type of error. If the error occurs in the logical-record path, the ERRSTAT field contains a status code issued by CA IDMS/DB with a major code from 00 to 19. For a list of these codes, see ERRSTAT Field and Codes.

When the error occurs in the request itself, LRF returns the path status LR-ERROR to the LRSTAT field of the LRC block and places a status code with a major code of 20 in the ERRSTAT field of the IDMS communications block. These codes are listed in Testing for the Logical-Record Path Status.