0

Tomorrow will be a work day for me =(. Colls, i need that sql script wait an end of sql*loader work in my -bash script. Is it right code below?:

#!/bin/bash

echo -------- uploader.sh v 0.1 --------
# @echo; 

export NLS_LANG=russian_cis.ru8pc866
export NLS_NUMERIC_CHARACTERS='.'

ORACLE_HOME=/opt/app/oracle/product/10.2.0/db_1/bin
export ORACLE_HOME
PATH=$ORACLE_HOME
export PATH

sqlldr userid=myscheme/0611@TEST_DB control=control_file.ctl LOG=test_log.log errors=100


wait #here i want to wait sqlloader executing

sqlplus userid=myscheme/0611@TEST_DB 10.33.19.13/test/DATA_UPLOAD/mysql_script.sql

I've read about wait function here.

May12
  • 2,420
  • 12
  • 63
  • 99

1 Answers1

2

Shell scripts, by default, only execute commands after the previous command has completed. The only exception to this is when you execute something in a background thread using &. So executing

sqlldr userid=myscheme/0611@TEST_DB control=control_file.ctl LOG=test_log.log errors=100
sqlplus userid=myscheme/0611@TEST_DB 10.33.19.13/test/DATA_UPLOAD/mysql_script.sql

will already do what you want.

However, if you want to use a separate thread so you can continue execution in the main thread, you can use

sqlldr userid=myscheme/0611@TEST_DB control=control_file.ctl LOG=test_log.log errors=100 &
pid=$!
#do other stuff
wait $pid
sqlplus userid=myscheme/0611@TEST_DB 10.33.19.13/test/DATA_UPLOAD/mysql_script.sql

That will allow you to do other stuff while the sqlldr command finishes. The program would then wait for the sqlldr command to complete before calling sqlplus.

Tim Pote
  • 27,191
  • 6
  • 63
  • 65
  • Ups, sorry, i didn't understand "if you put your sqlldr command to background with sqlldr &". Could you explain? – May12 Apr 27 '12 at 14:54