Solved

SQLLDR - Create a control file dinamically

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

758 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

21 Experts available now in Live!

Get 1:1 Help Now