Solved

Excecute sql scripts with SqlPlus in shell script

Posted on 2011-09-03
3
759 Views
Last Modified: 2012-05-12
I want to execute a sql script with SqlPlus in a shell script.  Something like this:

sqlplus usr/pwd@SID @../../procedures/insert_test.sql

This works and creates the procedure but ends with sqlplus still running:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning option
Procedure created.

SQL>

How should this be done so that sqlplus closes after the procedure is created?
0
Comment
Question by:jkavx
3 Comments
 
LVL 51

Assisted Solution

by:HainKurt
HainKurt earned 150 total points
ID: 36479407
add

/

or add

exit;
/
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 350 total points
ID: 36479990
The other (non-traditional, more restricted) way is to just pipe the script in:
  sqlplus usr/pwd@SID < ../../procedures/insert_test.sql
0
 

Author Comment

by:jkavx
ID: 36480525
Thx.  I'm finding that piping the script in works.

 But I tried both / and exit; / and neither makes a difference.  The insert_test.sql itself ends with /.  I dont' know if that's a factor.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now