How to setup Oracle connection inside shell script?

Hi,

We have Oracle Connection parameters set up in file name "TESTDB" at location /abc/etc.When I try to run my shell script it does not connect to Oracle database. Please let me know how "TESTDB" file can be called inside script.

####################### Setting the directories #############################
CFG_DIR=/abc/etc/TESTDB
#################################################################################
#------Truncate the base table before loading today's data -------#

${ORACLE_HOME}/bin/sqlplus ${ORACLE_USER}/${ORACLE_PASSWD}@${ORACLE_SID} << EOF >> ${LOG_FILE} 2>&1
set serveroutput on;
TRUNCATE TABLE TBL_STG_LOAD;
COMMIT;
QUIT;
EOF

To run the script: $ > . ./scriptname.sh

Thanks
Sandy

Source your file: /abc/etc/TESTDB in your script right before trying to connect to DB:

. /abc/etc/TESTDB

OR

source /abc/etc/TESTDB
1 Like

What I see is that you are using a lot of variables... Are they correctly set before you execute your shellscript?
Execute it in debug mode and see what is says...

1 Like