Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to load with external tables depending on type record

User_RFKSXJun 1 2021

Hi,
I've always used SQL-Loader for loading external files on Oracle.
Every flat files has got fields terminated by ";" but in the same file I've got a different format depending on the first value.
For example myfile.dat is:

...
A;John;Brown
A;Maty;Green
B;car;red;ford
...

By using SQL-Loader I can use two distinct *.CTL as following:

LOAD DATA
INFILE ... myfile.dat
BADFILE ...
APPEND
INTO TABLE TABLE_1 WHEN type_record = 'A'
FIELDS TERMINATED BY ';'
TRAILING NULLCOLS
(type_record,
name,
sirname)

LOAD DATA
INFILE ... myfile.dat
BADFILE ...
APPEND
INTO TABLE TABLE_2 WHEN type_record = 'B'
FIELDS TERMINATED BY ';'
TRAILING NULLCOLS
(type_record,
vehicle,
colour,
brand)

Can I do such a thing by using external tables or in this case all the records of the myfile.dat must have the same format? I need to load into different tables depending on the fist value that is the type_record

Oracle version 10g

Thanks in advance!
Mark

This post has been answered by Paulzip on Jun 1 2021
Jump to Answer
Comments
Post Details
Added on Jun 1 2021
5 comments
1,565 views