Solved

SQLLDR - Create a control file dinamically

Posted on 2013-06-12
2
1,097 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
2 Comments
 
LVL 76

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get maximum transfer speed over LAN 4 85
ifconfig 4 50
how to configure linux OS using Ubuntu 7 47
Using sort and uniq to pare down large syslog 6 38
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
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…

825 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