0

I have created a CTL file that will read the data inside a CSV file. It loads the data from the CSV to the table in the database. I just want to ask if it is possible to set a table column to a specific cell on CSV file when loading data using sqlloader?

For example (CTL script):

INTO TABLE "DB"."TABLENAME"
TRUNCATE
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' AND '"'
TRAILING NULLCOLS
(
**COL1 (:A1),** - is it possible to set this column to a specific cell?
COL2,
COL3,
COL4,
LOAD_DATE SYSDATE
)

Thanks in advance. :)

user3462803
  • 170
  • 1
  • 2
  • 10

1 Answers1

0

Extend your table TABLENAME with an integer column, let's name it ROW#. Then modify your control file as follows ...

LOAD
INTO TABLE "DB"."TABLENAME"
TRUNCATE
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' AND '"'
TRAILING NULLCOLS
(
    COL1,
    COL2,
    COL3,
    COL4,
    LOAD_DATE SYSDATE,
    ROW# SEQUENCE
)

Then create a primary key on TABLENAME (ROW#).

Then create a view over your TABLENAME which contains a new column with the specific cell value from the specific row you need. This is an "SQL for beginners" and, moreover, outside the scope of the sql-loader tag, so from here onwards you are on your own.

peter.hrasko.sk
  • 4,043
  • 2
  • 19
  • 34