Skip to Main Content
  • Questions
  • Loading two files with one CTL having different column

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Avinash.

Asked: March 23, 2017 - 5:33 am UTC

Last updated: March 23, 2017 - 7:27 am UTC

Version: 11.2.0.4.0

Viewed 1000+ times

You Asked

Hello Tom,

Good Morning.

I am in need to load two csv files with same CTL through SQLLoader.

File f1 has 3 columns and ctl loads them in corresponding table columns.

But file f2 has 2 columns only(last column of f1 is not present).

f1 has cols : a,b,c
table has cols : col1,col2,col3
ctl has mapping for : a -> col1, b -> col2, c -> col3

f2 has cols : a,b

How do i achieve this loading ? Do I need to update CTL to put some default values if it does not find one or two separate ctls for corresponding files.

Regards,
Avinash

and Connor said...

If you put

TRAILING NULLCOLS

in your control file, it means if I do not find a entry in the file for the columns, then they will be null.

So if you control file contains:

(a,b,c)

and the file contains

data1,data2

then by default, we'd reject that record because we didnt find anything for 'c'.

But if you have TRAILING NULLCOLS, 'c' will be NULL as the row is loaded.

Is this answer out of date? If it is, please let us know via a Comment