Connecting to Oracle Database


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Connecting to Oracle Database
# 1  
Old 11-11-2004
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
# 2  
Old 11-11-2004
Take a look at this thread and search for others using the search function.
# 3  
Old 11-11-2004
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' ????
# 4  
Old 02-15-2008
Just a Small Question

Hi Pals..

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

Code:
#!/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 ..
# 5  
Old 05-02-2008
MySQL

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
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Identify a specific environment Oracle variable to connect a remote Oracle database ?

Good evening I nned your help pls, In an unix server i want to connect to a remote oracle databse server by sqlplus. I tried to find out the user/passwd and service name by env variable and all Ive got is this: ORACLE_SID_REPCOL=SCL_REPCOL ORACLE_SID=xmeta ORACLE_SID_TOL=SCL_PROTOLCOL... (2 Replies)
Discussion started by: alexcol
2 Replies

2. Solaris

Connecting to Oracle database

Hi guys, long time no typing :D I have problems when I try to connect to Oracle database from SQL Developer which is located on my Windows box. Server is running Solaris 11/11 and Oracle 11 enterprise. I can log in locally with sys account to database, start it up and shut it down but when I... (2 Replies)
Discussion started by: solaris_user
2 Replies

3. Shell Programming and Scripting

Connecting to oracle database

Hai i want to connect to oracle database from user input and create a view. ${ECHO} "Debut Creating View" ${ECHO} "Please Enter the User Name:" read user_name ${ECHO} "Please Enter the Connection String:" read con_string ${ECHO} "Please Enter the Password:" read pwd... (3 Replies)
Discussion started by: shenthil76
3 Replies

4. Shell Programming and Scripting

Connecting to Database

Hi, I want to write a shell script which connects to a Database, executes a set of SQLs and displays a message for every SQL that was run whether any records have been returned or not? Can anyone help me in this regard? Appreciate your help and concern. Thanks, Dave (1 Reply)
Discussion started by: yoursdavinder
1 Replies

5. Shell Programming and Scripting

Connecting to oracle database from shell script

Hi all, I am satyakiran , i am new to the forum. i never done shell scripts for connecting to the data base (oracle) and fetching the data from the database( thru sql select statements ) i want to know 1. how to connect to the data base(oracle) using shell script 2. how to retrieve data... (8 Replies)
Discussion started by: satyakiran
8 Replies

6. Shell Programming and Scripting

Problem in Connecting to Oracle Database using KornShell

Hello, I am very new to Scripting. I am having a Kornshell Script below for connecting to Oracle database. But getting an error while executing it. #!/bin/ksh ssh -X root@192.168.2.127 <perimuka> sleep 5 su - oracle sqlplus <mraghunandanan>/<peri123> <<eof Can anyone tell what is wrong... (3 Replies)
Discussion started by: mraghunandanan
3 Replies
Login or Register to Ask a Question