Re: Problems with LOAD
Posted in 1999
lmarther@my-deja.com wrote:
>
> In article <7kt2su$2pk$1@nnrp1.deja.com>,
> justerman@my-deja.com wrote:
> > I have a mysterious problem with LOAD clause.
> >
> > I have a file test.txt which has about twenty columns float numbers
> > divided by tabs. I would like to copy this table to my database. Table
> > at database have alltough more columns than my file. This is because I
> > want to forexample create a serial number for each row with informix.
> >
> > LOAD FROM 'path\\file' DELIMITER '<ctrl-i>' INSERT INTO> > testtable(col2,col3,col4,col5,etc);
>
> If the first column of your testtable is a serial number, try this:
> LOAD FROM 'path\\file' DELIMITER '<ctrl-i>' INSERT INTO> testtable(0,col2,col3,col4,col5,etc);
> >
> > After executing these following messages appeared:
> >
> > Error in load file line1
> > Number of values in load file is not equal to number of columns
> >
> > This is quite weird, because i wrote a test file where I had less
> > columns than in my table, and no problems occured...
This is because of the SERIAL column. You MUSt insert SOMETHING into
the SERIAL column. If you want the automatic next value inserted you
must insert a zero. By no loading the column you are inserting a NULL
which is not allowed. Try using dbload instead of the dbaccess LOAD
verb. Create a dbload command file like this:
FILE 'path/file' delimiter '<ctrl-i>' N; #where N is the # columns in
the file
INSERT INTO testtable( col1, col2, col3, col4, col5, col6, ...)
VALUES (0, f1, f2, f3, f4, f5, ...);
Then:
dbload -c commandfile -d database -l errlog -e maxerrs -n commitcount -r
Art S. Kagel