Connecting to Oracle Database

if[ $action = 'export' ];
sql="select username from dba_users where username = '$FromUser';"
check_FromUser=`ExecSql "$sql"`

I want to connect to Oracle database & check the users in the database, store the value in check_FromUser.
First how to connect to Oracle database from the shell script ?

Appreciate your reply in this regard......

Thanks

Take a look at this thread and search for others using the search function.

OR

u can redirect the sql's o/p to a file and read it to a variable.
This is waht we do while pulling up the informix database using 'dbaccess'

Is there any good way of doing it using 'dbaccess' ????

Hi Pals..

I have a shell script Which is calling a .sql file.

#!/bin/ksh
sqlplus -s userID/password@DB_INSTANCE @Test.sql & 
sqlplus -s  userID/password@DB_INSTANCE << EOF
exit
EOF

Is there any thing wrong in the above Code Snippet ???

The Test.sql and Testsql.sh are in the same directory ..

This code may help you

#!/bin/ksh

CHKLOGIN()
{
if sqlplus -s /nolog <<! >/dev/null 2>&1
WHENEVER SQLERROR EXIT 1;
CONNECT $1 ;
exit;
!
then

echo OK
else
echo NOK
fi

}

LOGIN_ID="$1" (This will take login/pwd u have to give it as 'scott/tiger' from cmd promt)

while [ "$LOGIN_ID" = "" -o `CHKLOGIN "$LOGIN_ID" "DUAL"` = "NOK" ]
do
if [ "$LOGIN_ID" = "" ];then
echo "Enter Login Userid/Passwd : \c"
read LOGIN_ID
else
echo "Enter Login Userid/Passwd : \c"
LOGIN_ID=""
fi
done

if sqlplus -s $LOGIN_ID @$TOP_path/sql/xxx.sql(or any package) > $LOGFILE
then
echo "Any thing u can do or can display sucessfull" >> $LOGFILE
else
echo "Installation of sql script is not successful" >> $LOGFILE
echo "Aborting......" >> $LOGFILE
exit 1
fi