1

如何将 LOAD DATA INFILE 语法与 Number Of line 一起插入到表中..?
我使用了这个查询:

LOAD DATA INFILE 'D:/home/TAM/input/Upload/DOC20120919000000.csv' INTO TABLE tb_t_doc_d 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n' 
IGNORE 1 LINES (rrn_no, new_color_cd, new_main_dealer_cd, new_zone_cd, new_branch_cd, new_destination_cd, @var)
SET process_id = '1209219999999999', transaction_id = 'DC201209219999', reference = 
trim(TRAILING '\r' FROM @var), created_dt = sysdate(), created_by = "DIDIT", updated_dt = 
sysdate(), updated_by = "DIDIT", file_line_no = ???? ;

我应该填写什么file_line_no = ????

4

1 回答 1

3

这应该有助于:

set @row = 0;
LOAD DATA INFILE 'D:/home/TAM/input/Upload/DOC20120919000000.csv' INTO TABLE tb_t_doc_d 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n' 
IGNORE 1 LINES (rrn_no, new_color_cd, new_main_dealer_cd, new_zone_cd, new_branch_cd,       new_destination_cd, @var)
SET process_id = '1209219999999999', transaction_id = 'DC201209219999', reference = 
trim(TRAILING '\r' FROM @var), created_dt = sysdate(), created_by = "DIDIT", updated_dt = 
sysdate(), updated_by = "DIDIT", file_line_no = @row:=@row+1;
于 2012-09-24T09:07:36.130 回答