Adding a Field to a Database File
If a field is added to the end of a database file record format, compiling the new file definition with LVLCHK(*NO) does not always save you the effort of recompiling all the programs that use the file. If the new field is numeric, any programs that add records to the file should be recompiled anyway.
You may not be aware of the disadvantages of the following steps which programmers often use to add a new field to an AS/400 database file:
o Delete any logical files that are built over the file to be changed.
o Rename the existing file to save the current data.
o Modify the DDS for the file by adding the new field to the end of the existing record format.
o Compile the new file definition with LVLCHK(*NO).
o Copy the data back from the renamed file using the Copy File (CPYF) command with FMTOPT (*MAP *DROP).
o Recreate the logical files using LVLCHK(*NO).
Because the new file is compiled with LVLCHK(*NO), all existing programs which do not refer to the new field will work normally with the new version of the file, with one exception.
The exception has to do with the initialization of the new field when new records are written. When a program that was compiled with the old version of the file writes new records to the file, the new field will be properly initialized to blanks if it is alphanumeric. However, if the new field is numeric, it will not be initialized to zero and will contain invalid data.
LATEST COMMENTS
MC Press Online