Sharing existing record format descriptions in a database file
A record format can be described once in either a physical or a logical file (except a join logical file) and can be used by many files. When you describe a new file, you can specify that the record format of an existing file is to be used by the new file.
Sharing existing record format descriptions can help reduce the number of DDS statements that you normally code to describe a record format in a new file and can save auxiliary storage space.
The file originally describing the record format can be deleted without affecting the files sharing the record format. After the last file using the record format is deleted, the system automatically deletes the record format description.
The following example shows the DDS for two files. The first file describes a record format, and the second file shares the record format of the first file:
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R RECORD1 PFILE(CUSMSTP) A CUST A NAME A ADDR A SEARCH A K CUST A|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R RECORD1 PFILE(CUSMSTP) A FORMAT(CUSMSTL) A K NAME AThe first example shows file CUSMSTL, in which the fields Cust, Name, Addr, and Search make up the record format. The Cust field is specified as a key field.
The DDS in the second example shows file CUSTMSTL1, in which the FORMAT keyword names CUSMSTL to supply the record format. The record format name must be RECORD1, the same as the record format name shown in the first example. Because the files are sharing the same format, both files have fields Cust, Name, Addr, and Search in the record format. In file CUSMSTL1, a different key field, Name is specified. The following restrictions apply to shared record formats:
- A physical file cannot share the format of a logical file.
- A join logical file cannot share the format of another file, and another file cannot share the format of a join logical file.
- A view cannot share the format of another file, and another file cannot share the format of a view. (In the Structured Query Language (SQL), a view is an alternative representation of data from one or more tables. It can include all or some of the columns contained in the table or tables on which it is defined.)
If the original record format is changed by deleting all related files and creating the original file and all the related files again, it is changed for all files that share it. If only the file with the original format is deleted and re-created with a new record format, all files previously sharing that file's format continue to use the original format.
If a logical file is defined but no field descriptions are specified and the FORMAT keyword is not specified, the record format of the first physical file (specified first on the PFILE keyword for the logical file) is automatically shared. The record format name specified in the logical file must be the same as the record format name specified in the physical file.
To find out if a file shares a format with another file, use the RCDFMT parameter on the Display Database Relations (DSPDBR) command.
- Record format relationships between physical and logical files
When you change, add, or delete fields with the Change Physical File (CHGPF) command, a certain relationship exists between the physical and logical files that share the same record format.
- Record format sharing limitation with physical and logical files
You might encounter this record format sharing limitation when you are duplicating the same database object multiple times.
Parent topic:
Describing database files using DDS