user6157109
user6157109

Reputation: 63

Skip first 2 rows when loading Table using sql loader

Currently my control file is as :

Load data
Infile '/.../../emp*.txt'
Append into table emp_load
When (emp_id <> 'emp_id')
Fields terminated by "," optionally enclosed by ' " '
Trailing nullcols
(Emp_id "TRIM(:EMP_ID)",
EMP_NAME "TRIM(:EMP_NAME)",
SAL "TRIM(:SAL)"
)

Current input file :

Emp_id,emp_name,sal
1,A,100
2,B,200

I now have another requirement where the input files wil contain 2 headers and will be like

/folder1/folder2/file1_<date>.csv
Emp_id,emp_name,sal
1,A, 100
2,B,200
...

Similarly I will have multiple input files ...

Can you please help me with the control file for this scenario ?

Upvotes: 4

Views: 20517

Answers (1)

Gary_W
Gary_W

Reputation: 10360

You need the SKIP=2 OPTIONS clause.

OPTIONS (SKIP=2) 
Load data
Infile '/.../../emp*.txt'
Append into table emp_load
When (emp_id <> 'emp_id')
Fields terminated by "," optionally enclosed by ' " '
Trailing nullcols
(Emp_id "TRIM(:EMP_ID)",
EMP_NAME "TRIM(:EMP_NAME)",
SAL "TRIM(:SAL)"
)

See here for more info: https://docs.oracle.com/cd/B28359_01/server.111/b28319/ldr_control_file.htm#i1004816

Upvotes: 8

Related Questions