2013-10-13 64 views
0

嗨我有CSV文件有兩列id_a和id_b,但我需要再插入4列; ie. emp_sal_a, emp_sal_b, emp_dept_a, emp_dept_b using sqlldr。所以,我的當前控制文件看起來像:使用sqlloader在表格中加載CSV文件

load data 
infile '/home/.../employee.txt' 
into table employee 
fields terminated by "," 
(id_a, id_b, 
emp_sal_a ":id_a+1000", emp_sal_b "id_b+1000", emp_dept_a "10", emp_dept_b "20") 

但我得到的錯誤:invalid binding variables

請儘快幫忙。

+0

所以假設你試圖通過操作其中一個操作來創建列值是正確的C正在導入的列? – ermagana

+0

@ermagana是的正確 – user2875329

+0

爲什麼你用'mysql'標記這個? 'sqlldr'是一個Oracle工具? –

回答

0

MySQL Load Data Ref
注:搜索「(」字,它是它的頁面

User variables in the SET clause can be used in several ways. The following example uses the first input column directly for the value of t1.column1, and assigns the second input column to a user variable that is subjected to a division operation before being used for the value of t1.column2:

LOAD DATA INFILE 'file.txt' 
INTO TABLE t1 
(column1, @var1) 
SET column2 = @var1/100; 

@ var1的第35例是要一個變量的名稱運行一個操作,你正在做的是調用column2上的SET等於@ var1/100。