How to execute an Oracle procedure using shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to execute an Oracle procedure using shell
# 1  
Old 06-17-2008
How to execute an Oracle procedure using shell

Hi ,

i have created an .sh file that has the following code:

#!/bin/ksh
sqlplus -s p1istuat/p1istuat@CWS_IST6 @Procedure_Execute.sql &
sqlplus -s p1istuat/p1istuat@CWS_IST6 << EOF
exit
EOF

The mentioned Procedure_Execute.sql file inside has the following code:

exec TEST;


i tried to run the shell file as "sh filename.sh" its giving me as sqlplus cannot be found...

please let me know any solution for this....
# 2  
Old 06-17-2008
Bug chk ur sqlplus

chk whethere oracle is installed in ur unix machine ....

if installled check the path
to check the location of installation
try which command

/home/mkdmt/src/sh: which sqlplus
/opt/dbms01/app/oracle/product/10.2.0.2/bin/sqlplus
# 3  
Old 06-17-2008
How to execute an Oracle procedure using shell

Hi ,

Thanks a lot .I have checked for that.Its giving me :

Unknown user: optier

Also i have done saying echo $ ORACLE_HOME seems there is no oracle installed in that machine.

i have changed the entire .sh file to the following :

part_info=`sqlplus p1istuat/p1uatist@CWS_IST6 <<_EOF_
set serveroutput on size 10000
declare
abc integer;
begin
TEST;
dbms_output.put_line('return code is:') ;
end;
/
exit;
_EOF_`

i got the above code from some forum.
In this case how to see the output means how can i view 'part_info'
# 4  
Old 06-17-2008
How to execute an Oracle procedure using shell

Smilie no reply??????
# 5  
Old 06-17-2008
It's not allowed to bump up questions, please read our rules.
# 6  
Old 06-17-2008
Hi vins,

You are already got the above 90% stuff for executing the Stored Procedure from Shell Script. Why you are repeating the question ?????



RETVAL=`sqlplus -s USERNAME/PASSWORD@DBNAME <<EOF
SET SERVEROUTPUT ON SIZE 100000
Declare
OUT_STATUS NUMBER;
OUT_MSG VARCHAR2(200);
Begin
ODS_SP_REMOVE_PRE_SUB_DUP(OUT_STATUS, OUT_MSG);
dbms_output.put_line ('KeepThis '||OUT_STATUS ||' '||nvl(OUT_MSG,''));
End;
/
SET SERVEROUTPUT OFF
EXIT;
EOF`

X=`echo $RETVAL | grep KeepThis | awk '{print $2}'`
Y=`echo $RETVAL | grep KeepThis | awk '{print $3}'`

echo "Procedure: ODS_SP_REMOVE_PRE_SUB_DUP output is: "
echo "OUT_STATUS= $X"
echo "OUT_MSG= $Y "


Note: Set the Environmentol variables ($ORACLE_HOME, $PATH, $ORACLE_BASE, $ORACLE_SID, $TNS_ADMIN)are must before call the Oracle Stored Procedure.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to execute Oracle procedure and trigerring email on success and failure

Here is the shell script which need to trigger a stored procedure and when the record count is 0 then it should capture in the log that 0 duplicate records are found and if it's more than 0 then log with no of records. Also if there is any sqlerror then it should write the same in the log file and... (17 Replies)
Discussion started by: senmng
17 Replies

2. Shell Programming and Scripting

Why i can't execute the procedure in shell script?

i have the following code inside a shell script .prog in oracle server when i call the program DBMS_OUTPUT.PUT_LINE(x_return_status|| ln_rep_req_id); will return 0 , it is very strange , i try to submit the concurrent request in oracle , and it can successfully executed, what am i missing ? i... (1 Reply)
Discussion started by: feilhk
1 Replies

3. Shell Programming and Scripting

Execute a shell script from Oracle procedure

Hi Gurus, Want to execute a shell script from a oracle procedure and get the status of the same, any assistance in this regard will be appreciated. proc_data.sh is script name which I want to execute from oracle procedure It should work something like below procedure test begin... (1 Reply)
Discussion started by: palanisvr
1 Replies

4. Shell Programming and Scripting

Shell Linux to connect to a database and execute store procedure

HI, i want to write a script (Linux) that: 1) connect to a database oracle 2) execute some store procedure. Can anybody help me, please? Thanks a lot Andrew (3 Replies)
Discussion started by: manichino74
3 Replies

5. Shell Programming and Scripting

How to execute the stored procedure from shell script

How to execute the stored procedure from shell script and is there any possibility to print the dbms output in a log file. (2 Replies)
Discussion started by: dineshmurs
2 Replies

6. Shell Programming and Scripting

how to call oracle stored procedure from unix shell

Hi i want to call a oracle stored procedure from unix (using bash shell). consider this is my oracle stored procedure with parameter create procedure testproc(name IN varchar, age IN Number, id OUT Number ) AS begin id=1; dbms_output.put.line('successfull validation') end;... (6 Replies)
Discussion started by: barani75
6 Replies

7. Shell Programming and Scripting

Shell Script for call a procedure in Oracle DB

Hi everyone! I'm new with Shell Scripting, and I have to do a shell script to call a procedure, which have 2 input parameters, the directory(from server) and the txt file (which have informations to update/insert in DB). I have to create a shell script to execute that procedure for each txt... (5 Replies)
Discussion started by: renatoal
5 Replies

8. Shell Programming and Scripting

run shell script from oracle store procedure

hi, this is urgent..can i run a shell script from store procedure without using java. (8 Replies)
Discussion started by: arnabb4u
8 Replies

9. Shell Programming and Scripting

Shell arrays in oracle stored procedure

Is it possible to pass unix shell arrays in Oracle stored procedure? Is yes, how? Thanks (6 Replies)
Discussion started by: superprogrammer
6 Replies

10. Shell Programming and Scripting

Execute an Oracle stored procedure from a shell scrip

Here is a snippet of my code: if then echo "\n Deleting all reports older than 24 hours. \n" >> $logfile ls -l $FileName >> $logfile ... (1 Reply)
Discussion started by: mh53j_fe
1 Replies
Login or Register to Ask a Question