Solved

SQLLDR - Create a control file dinamically

Posted on 2013-06-12
2
1,094 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to take different types of Oracle backups using RMAN.

943 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

Need Help in Real-Time?

Connect with top rated Experts

1 Experts available now in Live!

Get 1:1 Help Now