Home > database >  For help, oracle using SQLLDR import multiple TXT to a table, want to implement a field in the table
For help, oracle using SQLLDR import multiple TXT to a table, want to implement a field in the table

Time:10-02

1, table test_member structure is the name, code, department
2, dept1. TXT file content is:
Technology department
Zhang SAN. 2013123
Li si. 2013234
Fifty. 2013345

Dept2. TXT file content is:
Purchasing department
Chen six; 2013123
Zhao qi; 2013234
Sun eight; 2013345

3, my idea is that in the CTL control file, in a similar case when the condition judgment, the department in the table according to the different TXT assign different values, such as:
The load data
Characterset al32utf8
Infile "D: \ dept1. TXT"
Infile "D: \ dept2. TXT"
Into the table test_member (
The name terminated by '; '
Code terminated by whitespace
Department constant (case when infile="D: \ dept1 TXT" then "technology" the when infile="D: \ dept2. TXT" then "purchasing" else "" end)
)
This case the when I was a shot in the dark, so please look great god, I want to achieve SQLLDR table fields according to different infile how to assign a different default values, change how to do? If I think this case the when feasible, the control file should how to write?

CodePudding user response:

Found no such option, but the following two methods, you consult

1, write multiple control files, separate import

2, combine multiple file processing, to a file;

CodePudding user response:

reference 1st floor wmxcn2000 response:
found no such option, but the following two methods, you consult

1, write multiple control files, separate import

2, combine multiple file processing, to a file;


Thank you for your help to advise,
I have hundreds of TXT file is more, a TXT a control file, the control file and I will write hundreds of,

I with your idea about the second method, now stuck in here, I want to by batch, each TXT file, each row of the most the right side of the stitching on the contents of the first line, such as each TXT format by the following:

Technology department
Zhang SAN. 2013123
Li si. 2013234
Fifty. 2013345

By batch into this style:
Technology department; Technology department
Zhang SAN. 2013123; Technology department
Li si. 2013234; Technology department
Fifty. 2013345; Technology department

Now is don't know how to write the batch change

CodePudding user response:

Should be this, the building Lord first study the

FOR/F % % I IN (file) DO the command

CodePudding user response:

Hundreds of such hyperbole

That should be a program to generate,

If can consider to put a semicolon is a small amount of files into a comma, into a CSV file format, open, add a list of departments, into a TXT file format, TXT again in the open, the comma to a semicolon,

Is to write the manual live,
  • Related