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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
pass variable from awk to shell script user_prady Shell Programming and Scripting 3 04-17-2008 05:43 AM
Is it possible to pass variable from awk to shell back unishiva Shell Programming and Scripting 12 03-03-2008 01:44 PM
How to pass Shell script variable to awk HIMANI UNIX for Dummies Questions & Answers 3 07-16-2007 12:23 AM
how to pass values from oracle sql plus to unix shell script trichyselva UNIX for Dummies Questions & Answers 2 02-24-2006 10:19 AM
How to Pass variable to shell Script sam70 UNIX for Dummies Questions & Answers 5 08-23-2005 07:27 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-08-2005
Jtrinh Jtrinh is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 7
How to pass a oracle variable back to the shell script

Hi,

I am calling an oracle function that returns a number (either 0 or 2), how do I pass that pass to the wrapping shell script as I would like to do other things based on the value returned by the oracle function.

Your help will be appreciated.

--------------------------
sqlplus / << ENDPROG
declare
return_code integer;
begin
return_code := kf_pkg_load.df_validate_file('SAS','20050612',null,null,null,null,null,null,null,null);
commit;
end;
/
exit;
ENDPROG
---------------------------
  #2 (permalink)  
Old 07-08-2005
vigsgb vigsgb is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 22
Quote:
Originally Posted by Jtrinh
Hi,

I am calling an oracle function that returns a number (either 0 or 2), how do I pass that pass to the wrapping shell script as I would like to do other things based on the value returned by the oracle function.

Your help will be appreciated.

--------------------------
sqlplus / << ENDPROG
declare
return_code integer;
begin
return_code := kf_pkg_load.df_validate_file('SAS','20050612',null,null,null,null,null,null,null,null);
commit;
end;
/
exit;
ENDPROG
---------------------------
Assign a variable to the sqlplus call. I belive you do not need to assign the
return code.

Code:
result=sqlplus / << ENDPROG
declare
return_code integer;
begin
return_code := kf_pkg_load.df_validate_file('SAS','20050612',null,null,null,null,null,null,null,null);
commit;                         
end;
/
This is how I would do it:

Code:
part_info=`sqlplus -s ${DB_USER:}/${DB_PASSWORD:}@${ORACLE_SID} <<_EOF_

      set feedback off
      set linesize 100
      whenever sqlerror exit failure;
      set lines 150
      set pages 0
      set head off
      set serveroutput on size 10000
  
      kf_pkg_load.df_validate_file 
      'SAS','20050612',null,null,null,null,null,null,null,null);
                    
      exit;
      _EOF_`
Then I evaluate the variable to get the results or see if an error occured. You should see what the df_validate_file returns or an error if one occured.

Hope this helps
  #3 (permalink)  
Old 07-10-2005
Jtrinh Jtrinh is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 7
Thanks VIGSGB for responding, I tried to run this (I had to make some changes to make it run):

----------------------------------
part_info=`sqlplus sars2d/oracle@kfdmlc <<_EOF_
set serveroutput on size 10000
declare
abc integer;
begin
abc:= kf_pkg_load.df_validate_file(
'SAS','20050612',null,null,null,null,null,null,null,null);
dbms_output.put_line('return code is:'||abc) ;
end;
/
exit;
_EOF_`
------------------------------

However, when I do an echo on part_info, it returns this:

------------------------------------
SQL*Plus: Release 9.2.0.1.0 - Production on Mon Jul 11 12:50:24 2005 Copyright (
c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i E
nterprise Edition Release 9.2.0.1.0 - 64bit Production With the Partitioning opt
ion JServer Release 9.2.0.1.0 - Production SQL> SQL> 2 3 4 5 6 7 8 start date is
: current load instance id is : last load instance id is : 122 return code is:0
PL/SQL procedure successfully completed. SQL> Disconnected from Oracle9i Enterpr
ise Edition Release 9.2.0.1.0 - 64bit Production With the Partitioning option JS
erver Release 9.2.0.1.0 - Production
-----------------------------------

What am I doing wrong?

Thanks in advance.

JTrinh
  #4 (permalink)  
Old 07-11-2005
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
You need to run sqlplus with the "-S" parameter to keep the sqlplus version text from muddying up your process.
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 08:50 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