sqlldr not found when using SQL*Loader in a shell script

Angelina picture Angelina · May 17, 2013 · Viewed 35.3k times · Source

I would like to create shell script, AUTOLOAD that will, when ran, execute SQL*Loader with a set of instructions. All this is in my Linux environment.

SQL*loader will then import data to SQL developer

#!/bin/sh
#
echo -------- SQL loader --------
# @echo; 
#
sqlldr username@server1/password control=/folder1/ctrl/loader.ctl log=/folder1/load/results.l 

My shell script is located in root directory and this is where I will be calling other files from. But it is giving me error when I try to run it:

- line 6: sqlldr: command not found

I don't know how to specify path to SQL*Loader, since I am on Linux.

I am new to this...so Be gentle :(

Answer

glenn jackman picture glenn jackman · May 17, 2013

Try

locate sqlldr

That should return something like

/u01/app/oracle/product/11.2.0/xe/bin/sqlldr

Edit your ~/.profile and add at the bottom

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
PATH="$PATH:$ORACLE_HOME/bin"

Then re-load your profile with source ~/.profile (or log out and log back in), and you should be good to go.