Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQLLDR - Create a control file dinamically

Posted on 2013-06-12
2
Medium Priority
?
1,106 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Suggested Courses

610 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