?
Solved

Run Oracle stored procedure from linux

Posted on 2014-02-06
4
Medium Priority
?
1,519 Views
Last Modified: 2014-02-06
I have a stored procedure that I need to run from linux, from the command line, through a script.  How can I do so?
0
Comment
Question by:newtoperlpgm
  • 2
4 Comments
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 800 total points
ID: 39840406
create a script like this...

exec procedure_owner.procedure_name(param1,param2);
exit

Open in new window



to execute the script

sqlplus username/password@yourdb  @your_script

Open in new window

0
 

Author Comment

by:newtoperlpgm
ID: 39840418
Don't I need to have a shell script or something of the sort setting the directories etc?
0
 
LVL 23

Accepted Solution

by:
Steve Wales earned 1200 total points
ID: 39840432
You can call that from a shell script:

Something like this ?

#!/bin/bash
export ORACLE_HOME=/u01/app/product/11.2.0/dbhome_1
export ORACLE_SID=yourdb
export ORAENV_ASK=NO
export PATH=$PATH:/usr/local/bin

. /usr/local/bin/oraenv

$ORACLE_HOME/bin/sqlplus username/password@yourdb  @your_script

Open in new window


Setting ORACLE_SID isn't really necessary since ststuber declared the @yourdb in the call.

If you set ORACLE_SID in the script you don't need to specify @yourdb in the call.
0
 

Author Comment

by:newtoperlpgm
ID: 39840493
This is what I was looking for.  Thanks.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Suggested Courses

850 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