The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 03:06 AM
Values of value($$X) in unix shell script ganesh_111 Shell Programming and Scripting 5 09-22-2006 06:25 AM
Passing Values from a shell script dhananjaysk Shell Programming and Scripting 6 04-06-2006 09:33 AM
Passing Parameters and getting values back from a c program to Shell script Rajeshsu High Level Programming 5 08-22-2005 03:12 AM
Returning Values (shell Script) jennifer01 Shell Programming and Scripting 3 11-29-2001 06:31 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-10-2008
sachin.gangadha sachin.gangadha is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 37
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 (permalink)  
Old 04-10-2008
helper helper is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 25
Arrow

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 (permalink)  
Old 04-22-2008
sachin.gangadha sachin.gangadha is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 37
thank you so much!
  #4 (permalink)  
Old 04-22-2008
sachin.gangadha sachin.gangadha is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 37
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:30 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0