[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
DBMS Database Programming Manual


Previous Contents Index


STORE

Function

The STORE statement stores a new record in the database, establishes the record as an owner of an empty set of each set type for which the record is an owner record type, and connects the record as a member to the current set of each set type for which the record is an AUTOMATIC member record type.


record-name

names a subschema record type.

realm-name

names a subschema realm.

set-name

names a subschema set type.

stment

is an imperative statement executed for an on error condition.

stment2

is an imperative statement executed for a not on error condition.

Syntax Rules

  1. Realm-name cannot be specified more than once in the same STORE statement.
  2. Set-name cannot be specified more than once in the same STORE statement.

General Rules

  1. The STORE statement references the record-name in the user work area. You must move the data to be in record-name to the user work area before executing a STORE statement.
  2. If you specify the WITHIN option, the Database Control System (DBCS) stores a new record occurrence in one of the realms from the list of realm-names.
    If you do not specify the WITHIN option, the DBCS stores a new record occurrence in one valid subschema realm for that record type.
  3. If you specify the DBKEY option, the target area is determined by page size. If the page specified by the DB-KEY special register has space available, that page is the target area. Otherwise, the DBCS chooses the next page that has available space.
  4. After a successful STORE operation, the DB-KEY special register contains the database key for the record.
  5. The STORE statement stores a record occurrence of the record-name record type from your user work area to a single target area.
  6. If the DBCS can store record-name in more than one realm or area, the selected realm or area is unspecified.
  7. The successful STORE statement directs the DBCS to store these items in the target area:
    • Each record-name data item defined in the subschema.
    • The default value for any record-name data items defined in the schema but not defined (omitted) in the subschema. The schema DEFAULT clause defines the values for these omitted data items.
  8. The DBCS establishes the newly stored record as the owner record of an empty set for each set type for which record-name is defined as the owner record type.
  9. The DBCS connects the newly stored record as a member record of the current set of each set type for which record-name is defined as an AUTOMATIC member record type. The set criteria defined in the schema for that set type determine the position where the DBCS inserts record-name.
  10. Unless otherwise specified by the RETAINING clause (see Section 4.9.1, RETAINING Clause), these currency indicators point to the stored record:
    • Run unit
    • Realm
    • Record type
    • Set type for each set type the record owns, and for each set type of which it is an AUTOMATIC member
  11. The contents of the user work area do not change after the successful or unsuccessful execution of a STORE statement.
  12. If a database exception condition occurs during the processing of a STORE statement, the DBCS places a database exception condition code in the special register DB-CONDITION (see Technical Notes). This code identifies the condition.

Technical Notes

STORE statement execution can result in these DB-CONDITION database exception condition codes:

DBM$_NODEFVAL There is no schema DEFAULT clause for an omitted data item in record-name.
DBM$_CHKITEM A record-name item contains an invalid value as determined by a schema CHECK clause.
DBM$_CHKMEMBER A record-name item contains an invalid value as determined by a schema CHECK clause.
DBM$_CHKRECORD A record-name item contains an invalid value as determined by a schema CHECK clause.
DBM$_CSTYP_NULL The set currency indicator for an AUTOMATIC, nonsingular set type in which record-name is a member is null.
DBM$_CONVERR A data conversion error occurred in the STORE operation.
DBM$_ILLNCHAR Invalid character found in a numeric field.
DBM$_NONDIGIT Nonnumeric character found in a numeric field.
DBM$_OVERFLOW A data overflow error occurred in the STORE operation.
DBM$_TRUNCATION A data truncation error occurred in the STORE operation.
DBM$_UNDERFLOW A data underflow error occurred in the STORE operation.
DBM$_SETSELECT You cannot store this record using this subschema. Either add the specified set type to your subschema or use a different subschema.

Additional References

  • Section 2.2, on reserved words (database special registers)
  • HP COBOL Reference Manual, Chapter 6, section on scope of statements
  • Section 4.8.1, on database On Error condition
  • Section 5.14.1, on RETAINING clause
  • USE statement

Example


010-ADD-NEW-CLASS-RECORDS.

    DISPLAY "ENTER CLASS CODE".
    ACCEPT  CLASS_CODE.
    DISPLAY "ENTER CLASS DESCRIPTION".
    ACCEPT  CLASS_DESC.
    DISPLAY "ENTER CLASS STATUS".
    ACCEPT  CLASS_STATUS.

    STORE CLASS_REC WITHIN MAKE
          ON ERROR DISPLAY "ERROR STORING CLASS..."
                   PERFORM 200-STORE-CLASS-ERROR
          END-STORE.

USE

Function

The USE statement specifies Declaratives procedures to handle file input/output errors and database exception conditions. It can also specify procedures to be executed before the program processes a specific report group.

These procedures supplement the procedures in the COBOL Run-Time System and RMS.

USE is part of the COBOL ANSI standard.

Formats 1 and 2

Refer to the HP COBOL Reference Manual for Formats 1 and 2. Only Format 3 is applicable to DBMS DML.


DBM$_exception-condition

is a symbolic constant name beginning with the characters DBM$_. It identifies an Oracle CODASYL DBMS exception condition. Refer to the Oracle CODASYL DBMS documentation set for information on DML error and warning messages.

Syntax Rules

All Formats

  1. A USE statement can be used only in a sentence immediately after a section header in the Procedure Division Declaratives area. It must be the only statement in the sentence. The rest of the section can contain zero, one, or more paragraphs to define the particular USE procedures.
  2. The USE statement itself does not execute. It defines the conditions that cause execution of the associated USE procedure.
  3. Refer to HP COBOL Reference Manual for information on USE formats 1 and 2.

Format 3

  1. The DBM$_exception-condition argument must begin with these five characters: DBM$_.
  2. If the phrase USE [GLOBAL] FOR DB-EXCEPTION. occurs, it is the only USE procedure allowed in the program.
  3. Multiple occurrences of the USE statement can exist within a program only if the ON phrase is specified. DBM$_exception-condition in each USE statement must be unique. Multiple USE statements must not cause the simultaneous request for execution of more than one USE procedure. The OTHER phrase may be specified only once in a program.
  4. If a USE FOR DB-EXCEPTION statement does not specify the ON phrase, it must be the only occurrence of Format 3 of the USE statement in the program.

General Rules

All Formats

  1. At run time, two special precedence rules apply for the selection of a USE procedure when a program is contained within another program. In applying these rules, only the first qualifying USE procedure is selected for execution. The order of precedence for the selection of a USE procedure is as follows:
    • First, select the USE procedure within the program containing the statement that caused the qualifying condition.
    • If a USE procedure is not found in the program using the previous rule, the Run-Time System searches all programs directly or indirectly containing that program for a USE GLOBAL... Declaratives procedure. This search continues until the Run-Time System either: (a) finds an applicable USE GLOBAL Declaratives procedure, or (b) finds the outermost containing program, if there is no applicable USE GLOBAL Declaratives. Either condition terminates the search.
  2. A USE procedure cannot refer to a non-Declaratives procedure. However, only the PERFORM statement can transfer execution control from:
    • A Declaratives procedure to another Declaratives procedure
    • A non-Declaratives procedure to a Declaratives procedure
  3. After a USE procedure executes, control returns to the next executable statement in the invoking routine, if one is defined. Otherwise, control transfers according to the rules for Explicit and Implicit Transfers of Control.
  4. A program must not execute a statement in a USE procedure that would cause execution of a USE procedure that had been previously executed and had not yet returned control to the routine that invoked it.


Previous Next Contents Index