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 SQL Loader from Unix

Status
Not open for further replies.

jones54

Programmer
Sep 2, 2003
23
IE

Hi,

I have a Unix script, from which I call SQL Loader to load data into an Oracle database. I then want to run some more commands after this but only if the SQL Loader insert completed successfully.

Is there any way I can tell from my Unix Script whether or not the SQL Loader insert completed successfully?

Any ideas or suggestions appreciated.

Thanks
 

You could try checking for $? return code after sqlldr executes. [3eyes]



----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 

-- OR --

Grep the sqlldr log:

rr=0; rd=0; err=0;
typeset -i rr=`grep "Total logical records rejected:" MySqlldr.log|awk '{print $5;}'`
typeset -i rd=`grep "Total logical records discarded:" MySqlldr.log|awk '{print $5;}'`
((err=rr+rc))
if [ err -gt 0 ]
then
echo "$err Errors."
fi


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Thanks for your help LKBrwnDBA

Your first suggestion seems to work.

I tried a few scenarios and it returns an error code greater than zero if there is any problem with the SQL Load e.g. primary key violation, incorrect password, incorrect instance name ....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top