Solved

Shell script

Posted on 2013-05-21
4
653 Views
Last Modified: 2013-05-23
Hi ,

I have to load data to 50+ tables using sqlloader. I have separate flatfile, control file for each table .first time i ran the sqlloader command manually for each table. But now i want to put all the sqlloder commands in a shell script and run 5 sqlloder commands parallel for 5 different tables. How would i do that.  I appreciate your help
Thank you
0
Comment
Question by:ajaybelde
[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
4 Comments
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 250 total points
ID: 39184079
Place the 5 sql loader commands in a single script file and place an '&' after each one.  This runs it in the background.

If you always want them to run no matter what add a nohup in front:

#/bin/ksh
nohup sqlldr control=controlfile1 &
nohup sqlldr control=controlfile2 &
etc...
0
 
LVL 23

Expert Comment

by:David
ID: 39184249
It seems a good solution, but not scalable to say, 50 tables.  After ensuring that the load was scripted to use parallel resources, I might approach using a for loop, as in:

for file in T1 T2 T3 ...T50.; do
nohup $ORACLE_HOME/bin/sqlldr control=control$file &
done

As an aside, remember to adjust your instance resources to optimize the I/O for this batch process.
0
 
LVL 35

Accepted Solution

by:
johnsone earned 250 total points
ID: 39184339
I would do it this way:

#/bin/ksh
sqlldr control=controlfile1 &
sqlldr control=controlfile2 &
sqlldr control=controlfile3 &
sqlldr control=controlfile4 &
sqlldr control=controlfile5 &
wait
sqlldr control=controlfile6 &
sqlldr control=controlfile7 &
sqlldr control=controlfile8 &
sqlldr control=controlfile9 &
sqlldr control=controlfile10 &
wait
....

That will send 5 off and then wait for those to complete before sending off the next 5.  There are ways to do that in a loop, but the commands would have to be pretty similar, or all contained in the control file.  You could loop through every file like this:

#/bin/ksh
wait_cnt=0
for f in *.ctl
do
  sqlldr control=$f &
  let wait_cnt +=1
  if [ $wait_cnt -eq 5 ] ; then
    wait
    wait_cnt=0
  fi
done
wait
0
 
LVL 7

Expert Comment

by:Docteur_Z
ID: 39192085
Thread is closed, but in case...
On system authorizing it, I would use at command with user job queues (queues 'g' to 'z')
echo $COMMAND1 | at - q g -t now
echo $COMMAND2 | at - q h -t now
echo $COMMAND3 | at - q i -t now
echo $COMMAND4 | at - q j -t now
echo $COMMAND5 | at - q k -t now
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This video shows how to recover a database from a user managed backup
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

623 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