Pillai’s

Technology and Everything…..

Archive for August, 2008

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

Posted in Technology | Tagged: | Leave a Comment »