Previous Topic: Updating the DatabaseNext Topic: Modifying Records


Storing Records

To add a record occurrence to the database, perform the following steps:

  1. Specify a subschema that includes:

    Note: Sets for which the stored record is defined as a manual member need not be defined in the subschema because the STORE statement does not access those sets. (An automatic member is connected automatically to the selected set occurrence when the record is stored; a manual member is not connected automatically to the selected set occurrence.)

  2. Ready all affected areas in one of the update usage modes (for more information, see Area Usage Modes).

    Areas should be readied whether they are affected explicitly or implicitly (for example, as owner of a mandatory automatic set whose members are being stored).

  3. Initialize the following variable storage fields:
  4. Establish currency for all set occurrences in which the stored record will participate as an automatic member. Depending on the set order, the stored record occurrence is positioned as follows:

    If the record being stored has a location mode of VIA, currency must be established for that VIA set, regardless of whether the record being stored is an automatic or manual member of that set. Current of the VIA set provides the suggested page for the record being stored.

  5. Issue the STORE command.
  6. Perform the IDMS-STATUS routine if the DBMS returns a nonzero value.

What STORE Does

STORE performs the following functions:

The program excerpt below shows storing records in the database.

The program establishes the proper DEPARTMENT and OFFICE currencies and stores the new EMPLOYEE record.

 PROCEDURE DIVISION.
          .
     READ NEW-EMP-FILE-IN.
          AT END MOVE 'Y' TO EOF-SW.
     PERFORM A300-STORE-EMP THRU A300-EXIT
                        UNTIL END-OF-FILE.
     FINISH.
     GOBACK.
 A300-STORE-EMP.
     MOVE DEPT-ID-IN TO DEPT-ID-0410.
*** ESTABLISH CORRECT DEPARTMENT CURRENCY ***
     FIND CALC DEPARTMENT.
*** CHECK FOR ERROR-STATUS = 0326 ***
     IF DB-REC-NOT-FOUND
        THEN DISPLAY
        'DEPARTMENT ' DEPT-ID-IN ' NOT FOUND'
        'FOR NEW EMPLOYEE ID ' EMP-ID-IN
        GO TO A300-GET-NEXT
     ELSE IF DB-STATUS-OK
        NEXT SENTENCE
     ELSE
        PERFORM IDMS-STATUS.
     MOVE OFFICE-CODE-IN TO OFFICE-CODE-0450.
*** ESTABLISH CORRECT OFFICE CURRENCY ***
     FIND CALC OFFICE.
*** CHECK FOR ERROR-STATUS = 0326 ***
     IF DB-REC-NOT-FOUND
        THEN DISPLAY
        'OFFICE ' OFFICE CODE-IN ' NOT FOUND'
        'FOR NEW EMPLOYEE ID ' NEW-EMP-ID
        GO TO A300-GET-NEXT
     ELSE IF DB-STATUS-OK
        NEXT SENTENCE
     ELSE
        PERFORM IDMS-STATUS.
     PERFORM B300-INITIALIZE-EMPLOYEE.
*** STORE EMPLOYEE RECORD ***
     STORE EMPLOYEE.
     PERFORM IDMS-STATUS.
     PERFORM U500-WRITE-NEW-EMP-REPORT.
 A300-GET-NEXT.
     READ NEW-EMP-FILE-IN
          AT END MOVE 'Y' TO EOF-SW.
 A300-EXIT.
     EXIT.