Connect to Oracle database

could someone please help me in shell scripting. i want to connect to oracle database which is on remote sever.
requirement:
1 want to check files in source directory if file exist then a execute a corresponding batch jobs on unix sever and fetch data from oracle database which is on remote server in order to do data validation being in unix server.
Thanks in advance.

Oracle supply a scriptable command line tool called sqlplus, you can do something similar to the following...(warning, untested off the top of my head example, terms and conditions apply your mileage may vary)

sqlplus -s user/pass@sid <<EOQ >dataset.csv
select interesting,fields from my_table where condition = 'met';
EOQ

Might I suggest changing this slightly:-

sqlplus -s  <<EOQ >dataset.csv
user/pass@sid
select interesting,fields from my_table where condition = 'met';
EOQ

The previous suggestion will leave the credentials available to anyone issuing a ps -ef|grep sql whilst your query is running.

Robin

1 Like