Utilities 7-21
How to Create a Command File
How to Create a Command File
Beforeyou use dbload, you first create an ASCII command file that names the
inputdata files andthe tables that receivethe data. The command file maps
fieldsfrom one or more input files into columns of one or more tables within
your database.
The command file contains onlyFILE and INSERT statements. EachFILE
statementnames an input data file. The FILE statement also defines thedata
fields from the input file that will be inserted into the table. EachINSERT
statementnames a table that will receive the data. The INSERT statement also
defines howdbload will place the data described in the FILE statement into
the columns of the table.
Withinthe command file, the FILE statement can appear in the following two
forms:
Delimiter form
Character-position form
Use the delimiter form of theFILE statement when every field in the input
data row uses the same delimiter and every row ends with aNEWLINE
character.This format is typical of data rows with variable-length fields. You
canalso use the delimiter form of the FILE statement with fixed-length fields
aslong as the data rows meet the delimiter and NEWLINE requirements. The
delimiterform of FILE and INSERT is easier to use than the character-position
form.
Use the character-position form of theFILE statement when you cannot rely
on delimiters and you need to identify the input data fields by character
position within the input row. For example, you would use this form to
indicate that the first input data field begins at character position 1 and
continues until character position 20.
Another reason to use this second form is if you must translate a character
stringinto the null value. For example, if your input data file uses a sequence
ofblanks to indicate a null value, you must use the second form if you want
to instructdbload to substitute null at every occurrence of the blank-
character string.