Question

I used oracle 10g and I have this file.ctl

OPTIONS (SKIP=1)
LOAD DATA
INFILE '/home/gxs/segmentation/sqlloader/datos.csv'
APPEND INTO TABLE test
(id "s_test.nextval",
name char(10) TERMINATED BY ',' ,
tel char(20) TERMINATED BY ',' ,
apellido char(10) TERMINATED BY ',' )

My csv file es

name,tel,apellido
daniel,12345,buitrago
cesar,98765,san
alex,4556,ova

but when see the table the name haven't the firs caracter:

id   name   apellido   tel
1    aniel  buitrago   12345
2    esar   san        98765
3    lex    ova        4556

What do?

Was it helpful?

Solution

As per the documentation, you need to use the EXPRESSION keyword to show that the value is coming purely from the specified expression and is not dependent on anything in the data file:

OPTIONS (SKIP=1)
LOAD DATA
INFILE '/home/gxs/segmentation/sqlloader/datos.csv'
APPEND INTO TABLE test
(id EXPRESSION "s_test.nextval",
name char(10) TERMINATED BY ',' ,
tel char(20) TERMINATED BY ',' ,
apellido char(10) TERMINATED BY ',' )

... which inserts:

        ID NAME       TEL        APELLIDO
---------- ---------- ---------- ----------
         1 daniel     12345      buitrago
         2 cesar      98765      san
         3 alex       4556       ova

At the moment it's assuming ID is a field in your data file, and since you haven't specified a data type it's defaulting to char with size 1, which is consuming the first character of your real first field.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top