passing values from sql to shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting passing values from sql to shell script
# 1  
Old 04-10-2008
passing values from sql to shell script

Hi guyz,

Posting a thread after a long time.

I want to pass two variables to unix shell script from sql script.

Note: I am calling sql script from unix script. sql script has 2 variables one is the return code for status of program run and second one email flag. I don't know how to capture email flag in unix.
# 2  
Old 04-10-2008
CPU & Memory

Hey dude, this question was asked before.. kindly check the replies for the same.
Anyways posting the reply.....


RETVAL=`sqlplus -s user/pwd@host <<EOF
SET SERVEROUTPUT ON SIZE 100000
Declare

OUT_MSG VARCHAR2(200);

Begin

select name into OUT_MSG from table_success;

dbms_output.put_line ('KeepThis '||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}'`
Z=`echo $RETVAL | grep KeepThis | awk '{print $4}'`


echo "The Query output is: "

echo "Query OUT_MSG 1= $X "
echo "Query OUT_MSG 2= $Y "
echo "Query OUT_MSG 3= $Z "

If you have more outputs from query, print those results in $5, $6,......
# 3  
Old 04-22-2008
thank you so much!
# 4  
Old 04-23-2008
Hi!

here is the sql statement within shell script

---------
---------

sqlplus system/manager@SID @myreport

myreport passes 3 values so how should i store it in a varibale.
i know i have to use array but i dont know how to use it.

Regards,

Sachin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing values to an XML file from shell script

:wall: Hi, I have an XML file with 5 tags. I need to pass values to the XML file from a shell script that will replace values in 2 of the tags. I cannot hardcode the tag values in XML and use replace command in script as the values are likely to change. Please help !!!!!!!!!!! (2 Replies)
Discussion started by: Monalisaa
2 Replies

2. Shell Programming and Scripting

Passing the result of an anonymous pl/sql block to a shell script

Hello, Here is the code i have written to get the count of a plsql query back to the unix. function checkforCOIDs { countcheck=`sqlplus -s $1/$2@$3 whenever oserror exit sql.oscode rollback whenever sqlerror exit sql.sqlcode rollback set serverout on size 2000; set head off feedback off... (2 Replies)
Discussion started by: santosh2eee
2 Replies

3. Shell Programming and Scripting

Passing PERL var values to SH Shell Script

Greetings all, If I have a SH script that calls a PERL script in the following way: perl $HOME/scripts/config.properties And in the config.properties PERL file, this Perl script only sets a number of environmental parameters in the following way: #!/usr/bin/perl $VAR1 = ( ... (3 Replies)
Discussion started by: gikyo12
3 Replies

4. Shell Programming and Scripting

passing values to the shell script

Hi, Solaris : 10 . I have 3 database in single file system i.e. /d01 . whenever I connect to oracle user using the below method #su - oracle It will prompt for which database environment you want to set(PROD,TEST,UAT) : whichever i need i will enter required DATABASE and perform my... (2 Replies)
Discussion started by: maooah
2 Replies

5. Shell Programming and Scripting

Passing filename dynamically in SPOOL of SQL*PLUS in shell script

Hi all, I am executing shell script in which I am using SQLLDR In this SQLLDR I am passing text file having PL/SQL script. This script will produce some formated output, this output I have to spool in another text file. Currently I have given this in script file as following Spool... (2 Replies)
Discussion started by: shekharjchandra
2 Replies

6. Shell Programming and Scripting

Help required in passing multiple arguments from a shell script to a pl/sql block

Hi, hope everyone are fine. Please find my issue below, and I request your help in the same In a configuration file, i have a variable defined as below TEST = 'One','Two','Three' I am trying to pass this variable in to a sql script which is define in a pl/sql block as follows, In the... (1 Reply)
Discussion started by: ramakanth_burra
1 Replies

7. Shell Programming and Scripting

Passing argumnets from shell script to sql

hi I all , I have sql statment in my shell script , I pass two argument to the script I need to pass the this two arguments to the sql statment example : runsql.sh "1" "2" sql : updat tables_x set y=0 where A=:x should subsituted by "1" and B=:y shuold subsituted bt "2"... (1 Reply)
Discussion started by: habuzahra
1 Replies

8. Shell Programming and Scripting

passing parameter from Shell-script to Sql-script

Dear Friends, Please help me to achieve the following: I want to pass one parameter from Shell-script to Sql-script. Example: My ShellScript.sh is calling report.sql like this: /bin/sqlplus /reports.sql And My report.sql is calling many Stored-Procedures like this: exec... (0 Replies)
Discussion started by: subodhbansal
0 Replies

9. Shell Programming and Scripting

Passing Values from a shell script

Hi all I want to know how to pass value from one shell script to another suppose i have script named A.This 'A.sh' calls 'B.sh' .Now some calculations are done by B.sh ..Say in variable X. Now i want to pass the value of this X variable to 'A.sh'... A.sh ----> B.sh ( X variable ) ... (6 Replies)
Discussion started by: dhananjaysk
6 Replies

10. Programming

Passing Parameters and getting values back from a c program to Shell script

I am having a shell script which has to be called from a C program. I have to pass two parameters to this script. HOw can I do that? eg: int main() { char st1; char str2; // call a shell script call_sh(str1,str2) where call_sh is the name of the shell script. then i need to get the return... (5 Replies)
Discussion started by: Rajeshsu
5 Replies
Login or Register to Ask a Question