Pillai’s

Technology and Everything…..

Accessing Oracle Database from Unix Shell Script

Posted by Shibu on August 5, 2008

Many times when you develop shell script for deployment or batch job often you have to check some database field values. I will show you how you can access database field value into unix shell variable.

DB_CHECK=NOTOK

DB_CHECK=`sqlplus -s user_name/<pass_word> <<EOF

set pages 0

set lines 2000

set heading off

select ‘OK’ from dual;

exit

EOF`

echo $DB_CHECK

Here you can have multiple line in the select statement. If you have multiple lines you have to put ‘\’ at the end of each line except the last line.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: