bdfd1m1iDatabase Administration

File Integrity

The following scenario addresses file integrity.

Problem

An application has destroyed an UP organized file because the program did not specify key parameters correctly when LRECs were added to the file.

Solution

With UP or DOWN organized files, always define the update keys as default keys in the DBDEF macro. The DBDEF statement overrules any key specifications in the DBADD macro or dfadd function. This maintains file integrity and eliminates the risk of application programs using incorrect key parameters when adding LRECs to a subfile.

The default keys are also used by the various ZUDFM commands. This prevents accidental corruption of the file organization. See TPFDF Utilities for more information about the ZUDFM command.

The TPFDF product checks that the primary key of the LREC to be added to the file is defined in the DBDEF. A mismatch results in a system error.

Note:
You can use any keys that you want, including partial keys, to read LRECs from a subfile. However, if you are adding LRECs, use the keys defined in the DBDEF.

DSECT Set Symbols

Not applicable.

DBDEF Statements

      DBDEF FILE=zzzzzz,                         -
            (PKY=#zzzzK80,                       -
            KEY1=(PKY=#zzzzK80,UP),              -
            KEY2=(R=zzzzFLD,UP))
 
      or
 
      DBDEF FILE=zzzzzz,                         -
            (PKY=#zzzzK80,                       -
            ORG=UP,                              -
            KEY1=(PKY=#zzzzK80),                 -
            KEY2=(R=zzzzFLD))

Application Coding

      DBADD REF=zzzzzz,NEWLREC=location
        TPFDF uses the keys defined in the DBDEF.
      DBRED REF=zzzzzz,KEY1=(PKY=#zzzzk80)
        TPFDF uses the keys specified in the application program