5. Populating Tables : Successful Use of the Copy Statement : Reloading Problems : Miscounted Fixed-Length Field Widths in the Copy File
 
Share this page                  
Miscounted Fixed-Length Field Widths in the Copy File
If the widths of fixed-length fields are not correct, the COPY statement can try to include data in a field that it cannot convert to the appropriate format.
For example, you receive an error message if you try to copy this row:
554-39-2699 01-oct-1998 Quinn 28000.00 Assistant
with the following COPY statement:
COPY TABLE personnel (ssno = CHAR(20),
    birthdate = CHAR(11), 
    name = CHAR(11),
    salary = CHAR(9), 
    title = CHAR(0)nl)
    FROM 'pers.data';
Because you specified char(20), or 20-character positions, for the ssno field, the COPY statement includes part of the birth date in the value for the ssno field. When the COPY statement tries to read the birth date, it reads “998 Quinn 2” which is not a valid date if birth date is defined as a date field; if defined as a char field, you get an “unexpected EOF” error.