How to fix connection to Oracle database through shell script?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to fix connection to Oracle database through shell script?
# 1  
Old 06-12-2015
How to fix connection to Oracle database through shell script?

I have a question regarding how to connect to Oracle Database through shell script.

1. If I want call a stored procedure on Linux server as this, it works.

Code:
$sqlplus /nolog

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 12 14:49:49 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> connect sysuser/password@SID as sysdba
Connected.
SQL> @tab_call.sql
     /

PL/SQL procedure successfully completed.


2. However, if I create a shell script to connect to database. It seems not connect and call stored procedure.
It didn't fetch any error message. My shell script like this:

Code:
#!/bin/ksh

sqlplus -s  /nolog <<EOF
connect sysuser/password@$SID as sysdba

@tab_call.sql

EOF
exit;

Please advise your comments. where is the problem and how to fix it. Thanks.

Last edited by Don Cragun; 06-12-2015 at 05:53 PM.. Reason: Add CODE and ICODE tags, again.
# 2  
Old 06-12-2015
Moderator's Comments:
Mod Comment This member has repeatedly ignored requests to use CODE tags as required by forum rules and is now placed in read-only mode for two weeks. Future infractions may results in a permanent ban for this user.
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 06-13-2015
Put a / in your shell script after the sql or inside the sql file (which you did from command line, but not from script)

Inside should be more standard,PL/SQL should have :
Code:
END;
/

at the end.

Regards
Peasant.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Oracle Database connection from UNIX

Hi I have a question regarding Oracle connection using the below code ${ORACLE_HOME}/bin/sqlplus -s $user/$pwd@$sid <<!EOF 1>> $v_log_dir/$v_job_log.out 2>> $v_log_dir/$v_job_log.err / prompt stored procedure beginning . . . exec xx_interface_pkg.pr_xx_clms_out($datayears,$keepmonths); ... (3 Replies)
Discussion started by: smilingraja
3 Replies

2. Shell Programming and Scripting

How to setup Oracle connection inside shell script?

Hi, We have Oracle Connection parameters set up in file name "TESTDB" at location /abc/etc.When I try to run my shell script it does not connect to Oracle database. Please let me know how "TESTDB" file can be called inside script. ####################### Setting the directories... (2 Replies)
Discussion started by: sandy162
2 Replies

3. Shell Programming and Scripting

How to connect to Oracle database using shell script?

Hi All, I am newbie to unix shell scripting. I want to connect to oracle database using shell script. I know how to connect DB using user name and password but my question is if my password is having '@' sign then how to connect. I have tried like below, cnt=`sqlplus -s /nolog << EOFSQL ... (3 Replies)
Discussion started by: pmotewar
3 Replies

4. Shell Programming and Scripting

Shell Script to connect to the oracle database

Hi Unix Gurus, I have a requirement to write a script, Oracle DB gets referesh every 6hrs, hence we need write a script to connect to the database , if it connects it should generate a file to proceed the next job application or when an error when connectiong to DB it should not generate any... (8 Replies)
Discussion started by: bshivali
8 Replies

5. Shell Programming and Scripting

Verifying oracle connection from shell script

Hi, Oracle 9.2 Solaris 10 From the shell script ........How can we verify whether oracle connection is successful or not ? Shell script will prompt the user to enter the oracle schema username, password and tns name. So, *how to verify whether oracle connection has been established or... (14 Replies)
Discussion started by: milink
14 Replies

6. 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

7. Shell Programming and Scripting

oracle connection from shell script

Hi, For connecting to oracle my script is using the command sqlplus username/password@db_instance_name.For this to work i am setting ORACLE_HOME,TNS_ADMIN and ORACLE_SID in a seperate script.My question is,could we make a connection to oracle just by the command sqlplus... (4 Replies)
Discussion started by: DILEEP410
4 Replies

8. Shell Programming and Scripting

Connection to database through shell script

Hi when i am calling the shell script with two parameter like id and date it works fine.But the same shell script is call by java application it gives the error as shown below Thu Jan 8 04:13:22 EST 2009|The Get Segment Process Failed: SP2-0306: Invalid option. Usage: CONN where <logon>... (1 Reply)
Discussion started by: ravi214u
1 Replies

9. Shell Programming and Scripting

shell script- oracle connection problem

Hi all, I am having problem with a shell script. I have a couple of csv files. The shell script will do some operation on them, create a sql file which will then be called by sqlplus. The problem is to gracefully exit sqlplus at the end of every operation as I do not want to hang on to the... (4 Replies)
Discussion started by: nattynatty
4 Replies
Login or Register to Ask a Question