Solved

SQLLDR - Create a control file dinamically

Posted on 2013-06-12
2
1,102 Views
Last Modified: 2013-06-12
Hello experts, I need to create a control file with some files data that already exists in a Linux directory.
Taking all files in:
/cots/oracle/TABLAS_HISTORICOS/VOLCADO_DATOS/TEST_SUR/DATOS_SUR_5MIN/

Open in new window

SUR_6TF4______I.SUR
SUR_6TF3______I.SUR
SUR_6TF2______I.SUR

Open in new window


I need to create:
control_5min_033.ctl

Open in new window

with text:
LOAD DATA
infile SUR_6TF4______I.SUR
infile SUR_6TF3______I.SUR
infile SUR_6TF2______I.SUR
INTO TABLE XAJTDB.temp_5MIN_033
Insert
fields terminated by "||"
OPTIONALLY ENCLOSED BY '"'
(UTCTIME Date "DD-MM-YYYY HH24:Mi:SS",
EPOCH Integer external,
valor_inst,
MS Integer,
TLQ Integer,
TAG Char,
PUNTO Integer external)

Open in new window

It is posible?

What method I must to use?

I need create automatically the control file, many times.

Thank you in advanced!

Regards
0
Comment
Question by:carlino70
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 39242033
Try this.   Just remove the file names from the control file.  This way you don't have to keep recreating it.

Then create a loop and pass in the files from the command line.

LOAD DATA
INTO TABLE XAJTDB.temp_5MIN_033
Insert
fields terminated by "||"
OPTIONALLY ENCLOSED BY '"'
(UTCTIME Date "DD-MM-YYYY HH24:Mi:SS",
EPOCH Integer external,
valor_inst,
MS Integer,
TLQ Integer,
TAG Char,
PUNTO Integer external) 

Open in new window


shell script
#!/bin/bash

FOLDER=/cots/oracle/TABLAS_HISTORICOS/VOLCADO_DATOS/TEST_SUR/DATOS_SUR_5MIN

for filename in $FOLDER/*.SUR
do
 sqlldr username/password control=control_5min_033.ctl data=$filename
done

Open in new window

0
 

Author Closing Comment

by:carlino70
ID: 39242355
Excellent!, It works fine

Thank you.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Via a live example, show how to take different types of Oracle backups using RMAN.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question