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
capture ftp return code..PLZ HELP anju Shell Programming and Scripting 3 04-03-2008 10:08 AM
how to capture the return value in master script? mahek_bedi UNIX for Dummies Questions & Answers 2 08-12-2007 06:43 AM
how to return an array of elements from oracle to shell script satyakiran Shell Programming and Scripting 3 08-02-2005 09:57 AM
Store return code of shell script in oracle table sveera Shell Programming and Scripting 3 05-04-2005 01:25 PM
return code from oracle lesstjm Shell Programming and Scripting 3 01-29-2002 03:50 PM

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 05-19-2006
Vikas Sood Vikas Sood is offline
Registered User
  
 

Join Date: May 2006
Posts: 32
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=$?
if [ ${ERROR} -ne 0 ]
then
echo "Failure" >> $LOGFILE
else
echo "Success" >> $LOGFILE
fi


Problem I am facing is, it does not log a 'success' or 'failure'. It simply skips the above if loop, even though the list variable contains resultset from oracle table.

Can anybody help me understand what exactly the problem is and how I can fix it?

Appreciate all the help, folks

Thanks
Vikas.
  #2 (permalink)  
Old 05-22-2006
rajeeb_d rajeeb_d is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 37
Try this

list=`sqlplus -s $user/$pwd@$dbms<<EOF
WHENEVER SQLERROR EXIT FAILURE
set pagesize 0 feedback off verify off heading off echo off

select * from control_tbl
where src_nm=$3
and extrct_nm=$4;
EOF`

ERROR=$?
if [ ${ERROR} -ne 0 ]
then
echo "Failure" >> $LOGFILE
else
echo "Success" >> $LOGFILE
fi
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 05:39 PM.


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