Oracle Sql Loader option to skip multiple extensions

When using the SQL Loader management file, do the following:

OPTIONS(**skip=1**,bindsize=1048576,rows=1024) LOAD DATA INFILE 'C:\Documents and Settings\FIRST.CSV' INFILE 'C:\Documents and Settings\SECOND.CSV' APPEND INTO TABLE table_name FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS ( fields ) 

it skips the header row for the FIRST.CSV file, but loads the header row from SECOND.CSV into the Oracle table. My solution is to split this management file into two separate files. Any way to execute a single management file?

+4
source share
1 answer

You can do it with one control file, but you still need to run sqlldr twice:

Control file:

 OPTIONS(skip=1,bindsize=1048576,rows=1024) LOAD DATA APPEND INTO TABLE table_name FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS ( fields ) 

And then run sqlldr as follows:

 sqlldr control=control.ctl data=FIRST.CSV sqlldr control=control.ctl data=SECOND.CSV 

Another option that just occurred to me is that you can check the record with the WHEN clause:

 OPTIONS(bindsize=1048576,rows=1024) LOAD DATA INFILE 'C:\Documents and Settings\FIRST.CSV' INFILE 'C:\Documents and Settings\SECOND.CSV' APPEND INTO TABLE table_name WHEN (field1 <> 'ContentsOfField1InHeaderRow') FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS ( fields ) 

If your title always contains fixed text, you can skip it based on the contents of (one of) the fields. Using WHEN can affect performance - depending on the size of the files, you might be better off with two sqlldr calls.

+6
source

All Articles