Return value from oracle to unix shell


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Return value from oracle to unix shell
# 1  
Old 11-28-2008
Return value from oracle to unix shell

Hi ,

i have written a shell scipt to call a procedure and get the value back from procedure.But i am facing the issue like
#!/bin/sh
returnedvalue=`sqlplus -s userid/pass<<EOF
set serveroutput on;
exec pass($1)
set serveroutput off;
EXIT;
EOF`
flag=`echo $returnedvalue `
echo "$flag" >
check.log
if [[ $flag == 1 ]]
then
echo "flag" >> check.log
else
echo "no flag" >> check.log
fi

Output i am getting as
flag =1 PL/SQL procedure successfully completed.

but i need only 1 as output not PL/SQL procedure successfully completed.

any help .
# 2  
Old 12-05-2008
Then use:

Code:
if echo "$flag" | grep "^1 " >/dev/null 
then 
...

# 3  
Old 12-05-2008
another way
you can specify "set feed off"
after "set serveroutput on" line
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to exit a shell script if a unix command does not return any value for 10 seconds?

Hi, Can anyone help me how to exit a shell script if a unix command inside does not return any value for 10 seconds? The scenarios is like this. I want to login to a application using shell script where the connection string is mentioned.but suppose this connection string is not... (10 Replies)
Discussion started by: arijitsaha
10 Replies

2. Shell Programming and Scripting

Need to get return code from mutt if an address is invalid/undeliverable from Unix shell script

I am using mutt on ksh Unix to send emails to addresses plucked from the database. If the "To:" email address is not longer valid and so the email is not sent to the "To:" recipient, but is sent to the valid cc address, I need to be able to get an error code returned to the shell script so that... (3 Replies)
Discussion started by: jzuber
3 Replies

3. Shell Programming and Scripting

how to store the return values of stored procedure in unix shell script.

hi i am calling a oracle stored procedure(in the database) from unix shell scripting (a.sh). the called stored procedure returns some values through OUT variables i want to assign the return values of stored procedure in to unix shell script variable. can you provide me the code. ... (1 Reply)
Discussion started by: barani75
1 Replies

4. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

5. HP-UX

return code from oracle to unix script

Hi I'm writing a shell script that connects to oracle database and fires query to check the availability of data in a table. In case of no data found then what will be the return code and how to handle in that in variable. Kindly provide with an example for better understanding... Thanks... (1 Reply)
Discussion started by: ksailesh
1 Replies

6. Shell Programming and Scripting

Getting value from oracle to unix shell

All, I am using Sun Solaris and Oracle 10g. I have a simple shell script returning a value. #!/usr/bin/ksh dummyvar=`sqlplus -s '/as sysdba' <<END set feedback off; set verify off; set serveroutput on; select num from scott.num1; END` echo $dummyvar For the above script - i... (5 Replies)
Discussion started by: user7509
5 Replies

7. UNIX for Dummies Questions & Answers

Enable a shell to collect data from unix, return to windows

hi I am very new to UNIX. I need to retrieve data from a unix system and store it and display as output on a windows system. Initiation of procedure is through JAVASCRIPT-based buttons on a HTML page. This should cause a set of commands to run which colllect data from a unix based server and... (1 Reply)
Discussion started by: rossalyn_maxter
1 Replies

8. Shell Programming and Scripting

Capture Oracle return code in shell script

I am using the following code in my shell script list=`sqlplus -s $user/$pwd@$dbms<<EOF WHENEVER SQLERROR EXIT SQL.SQLCODE set pagesize 0 feedback off verify off heading off echo off select * from control_tbl where src_nm=$3 and extrct_nm=$4; exit SQL.SQLCODE; EOF` ERROR=$?... (1 Reply)
Discussion started by: Vikas Sood
1 Replies

9. Shell Programming and Scripting

how to return an array of elements from oracle to shell script

Hi all, I have a interresting problem. My application is as follows: From a shell script i will conn to a oracle database and fetch few rows using a select statement. Then i want to sort these rows and return a column (collection of values of a column from the selected results) as array... (3 Replies)
Discussion started by: satyakiran
3 Replies

10. Shell Programming and Scripting

Store return code of shell script in oracle table

Hi friends, I have to do the following things : 1) there should be a shell script returning the returning the return code of the script. and i have to add some more details like on which machine is has run , at what time and other details and then using plsql i have to add a row to Oracle... (3 Replies)
Discussion started by: sveera
3 Replies
Login or Register to Ask a Question