Externally and program-described data

 

Programs can use either externally described or program-described files. Programs can use file descriptions in two ways:

However, if you choose to describe a file to the field level, the system can do more for you. For example, when you compile your programs, the system can extract information from an externally described file and automatically include field information in your programs. Therefore, you do not have to code the field information in each program that uses the file.

The following figure shows the typical relationships between files and programs on the system.

Examples of files

1 Externally Described Data

The program uses the field-level description of a file that is defined to the system. At compilation time, the language compiler copies the external description of the file into the program.

2 Program-Described Data

The program uses a file that is described to the field level to the system, but it does not use the actual field descriptions. At compilation time, the language compiler does not copy the external description of the file into the program. The fields in the file are described in the program. In this case, the field attributes (for example, field length) used in the program must be the same as the field attributes in the external description.

3 Program-Described Data

The program uses a file that is described only to the record level to the system. The fields in the file must be described in the program.

Externally described files can also be described in a program. You might want to use this method for compatibility with previous systems. For example, you want to run programs on a system that originally came from a traditional file system. Those programs use program-described data, and the file is described only to the record level. Later, you describe the file to the field level (externally described file) to use more of the database functions that are available on the system. Your old programs that contain program-described data can continue to use the externally described file while new programs use the field-level descriptions that are part of the file. Over time, you can change one or more of your old programs to use the field-level descriptions.

 

Parent topic:

How database files are described