Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling oracle procedure

Status
Not open for further replies.

sweetleaf

Programmer
Jan 16, 2001
439
CA
Hi,

I have a shell script that does 2 things.
Section1 calls an oracle procedure which creates a txt file and signal file (sig).

Section2 checks to ensure the files are created, then moves them to another directory.

My question:
Is it possible for section2 to begin processing before section1 is finished processing? If so, how can i get my script to wait and allow section1 to comlpete?

<the code is below>

#section1:
echo $PASSWORD | sqlplus -s sales@db1 @${SQL_DIR}/sales1.sql >>$LOG_FILE 2>&1


#section2:
SIG_FILES=$( ls -t file1_*.sig )
DAT_FILES=$( ls -t file1_*.txt )

if (( $( print ${SIG_FILES} | wc -w ) != $( print ${DAT_FILES} | wc -w ) )) then
#
# Consistency error # of sig files is not
# the same as # of txt files
#
print "ERROR: Consistency error in ${DIR1} directory ..." >>$LOG_FILE 2>&1
mailx -s "SALES EXPORT Script Error" -c $CC $TO < $LOG_FILE
exit 1
fi


 
Provided you move the file(s) in the same filesystem the inode number is preserved, so the sqlplus procedure will continue to write on the right place.
To start section2 before section1 is finished, simply add an ampersand (&) at the end of the sqlplus launch line.
Then add a sleep command to give a chance to have something to do.
Finally to wait section1 completion add a wait command.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
you can use &&

command1 && command2

command2 will only run if command1 works

also useful is ||

command1 || command2

in this case command2 would only run if command1 fails

or

use wait

eg

sort large_file > sorted_file &

wait
pg sorted_file

or

variables can be used

wait $! (to obtain the process number of the last process sent to background)




--
| Mike Nixon
| Unix Admin
|
----------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top