Previous Topic: ParametersNext Topic: Example


Usage

Effect of ADD on Records

ADD copies the record description from the schema description into the subschema. The record can be copied into the subschema with its primary name or with any of its synonyms.

Note: A record description can be copied only once into a subschema, regardless of the number of record synonyms that exist for that record.

The following illustrates the use of the ADD RECORD statement. The left-hand side illustrates the original schema record description. The right-hand side illustrates a subschema record description, a subset of the schema.

SCHEMA                                       SUBSCHEMA

ADD RECORD NAME IS EMPOSITION             ADD RECORD NAME IS EMPOSITION
   LOCATION MODE IS VIA EMP-POSITION SET       STORE IS NOT ALLOWED
   WITHIN EMP-DEMO-REGION AREA.                ERASE IS NOT ALLOWED
   02 POS-START-DATE.                          ELEMENTS ARE
      03 POS-START-YEAR   PIC 99.                  POS-FINISH-DATE
      03 POS-START-MONTH  PIC 99.                  POS-START-DATE.
      03 POS-START-DAY    PIC 99.            ┌───────────────┬────────────────┐
   02 POS-FINISH-DATE.                       │POS-FINISH-DATE│ POS-START-DATE │
      03 POS-FINISH-YEAR  PIC 99.            └───────────────┴────────────────┘
      03 POS-FINISH-MONTH PIC 99.
      03 POS-FINISH-DAY   PIC 99.
   02 POS-SALARY-GRADE    PIC 99.
   02 POS-SALARY-AMOUNT   PIC S9(7)V99 COMP-3.
   02 POS-BONUS-PERCENT   PIC S999 COMP-3.
   02 POS-COMM-PERCENT    PIC S999 COMP-3.
   02 POS-OVERTIME-RATE   PIC S999 COMP-3.
   ┌──────────────┬───────────────┬──┬─────────────┐
   │POS-START-DATE│POS-FINISH-DATE│  │             │
   ├─────┬─────┬──┴─┬─────────────┴──┴─────────────┘
   │     │     │    │               ▲       ▲
   └─────┴─────┴────┘   POS-SALARY-GRADE    │
      ▲     ▲     ▲     POS-SALARY-AMOUNT -─┘
      │     │     └──── POS-OVERTIME-RATE
      │     └────────── POS-COMM-PERCENT
      └──────────────── POS-BONUS-PERCENT

Effect of DELETE on Records

DELETE removes the record from the current subschema description in the dictionary; the record remains associated with the schema.

How DELETE RECORD Affects Set Definitions

If the record owns a subschema set, DELETE RECORD deletes the set. If the record is a member of a subschema set, DELETE RECORD has no effect on the set.

The subschema DELETE RECORD statement does not affect the schema description of sets.

How ELEMENTS and VIEW ID Clauses Determine the Record Description

The combination of the ELEMENTS clause specification and the VIEW ID clause specification determines which fields are copied into the subschema description of database-record-name. The following table lists the possible combinations of the ELEMENTS clause and VIEW ID clause specifications and the resulting subschema view of the record.

 

No VIEW ID Clause

VIEW ID Clause

No ELEMENTS Clause

All schema-defined fields

Fields defined for record identified by view ID

ELEMENTS ARE ALL

All schema-defined fields

All schema-defined fields; new view ID created

ELEMENTS ARE field name

Schema-defined fields named in ELEMENTS clause

Schema-defined fields named in ELEMENTS clause; new view ID created

Note: When the ELEMENTS clause is used for a view ID associated with other subschemas, the subschema compiler ignores the VIEW ID clause, creating a new subschema view with a null ID.

Considerations Specifying Fields in the ELEMENTS Clause

The following considerations apply to copying schema-defined fields into the subschema description of the record:

PRIORITY Clause Can Optimize Use of Subschema Tables at Runtime

The PRIORITY clause permits the DBA to optimize runtime use of the subschema tables when a frequently used subschema includes many record types, of which only a few are used heavily. Those records used most heavily should be assigned high priorities. The PRIORITY clause is useful primarily in subschemas in which only a few record types are accessed frequently.