Sponsored Content
Top Forums Shell Programming and Scripting how to capture oracle function returning 2 values in unix Post 302410756 by m1xram on Tuesday 6th of April 2010 07:17:11 PM
Old 04-06-2010
IO

As Durden indicates functions typically return a value. Even in languages such as Perl which can return arrays and lists they still return these values as a single entity.

With that said I'd like to ask a question. Do you know if the error value comes back from STDERR because the Oracle command fails?

Rather than waiting for an answer I'll assume the above to be the case where an error message is written to STDERR and the command returns a non-zero value as status. Here's some test code. The first script, 'test9a.sh', calls a second script, 'test9b.sh', which can return an error. The error is returned if you specify 'error' as the first parameter to the first script.
Code:
#!/bin/bash
# script test9a.sh

sfile=$(basename $0)

#echo "$sfile: start"
#echo "$sfile: param: $1"

err=""
rval=$(./test9b.sh $1 2>&1 )
rcode=$?
if [ $rcode -ne 0 ]; then 
    err="$rval"
    rval=""
fi
echo "$sfile: rcode=$rcode, rval=\"$rval\", err=\"$err\""

Code:
#!/bin/bash
#script test9b.sh

sfile=$(basename $0)

#echo "$sfile: start"
#echo "$sfile: param: $1"
if [ "$1" == "error" ]; then
    echo "$sfile: Error message" >&2
    exit 1
fi
echo "$sfile: Return Value $1"
exit 0

Try it out to see if these scripts emulate your situation.

Last edited by m1xram; 04-06-2010 at 08:39 PM.. Reason: Add scripts and answer
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to pass values from oracle sql plus to unix shell script

how to pass values from oracle sql plus to unix shell script (2 Replies)
Discussion started by: trichyselva
2 Replies

2. Programming

string returning function

I have two string returning function in ESQL/C char *segment_name(lbuffer) char *lbuffer; {..... and char *get_bpdvalue(f_name) char *f_name; {...... both declared above main() char *get_bpdvalue(); char *segment_name(); my problem is segment_name works on sprintf and strcpy... (5 Replies)
Discussion started by: jisc
5 Replies

3. Shell Programming and Scripting

Values from Oracle to Unix

Hello Experts how do I get a output value from Oracle to Unix . Please give me sample Unix codings Scenario (Filne name : test.sh <argument > ) --------- 1. Passing argument from unix to sql 2. connecting to Oracle & from oracle get output 3. Pass the output to ... (3 Replies)
Discussion started by: Krishnaramjis
3 Replies

4. Shell Programming and Scripting

returning from a function

Hi all, I am very new to BASH shell programming. I need to return an integer from a function to the caller function. I did this: but it keeps giving me wrong return: Can someone help me out here, please? Thanks (2 Replies)
Discussion started by: alirezan
2 Replies

5. Programming

returning multiple values from a function in C

hi how can I return multiple values from a C function. I tried the following: #include <stdio.h> void foo(int id, char *first_name, char *last_name) { /* this is just an example to illustrate my problem... real code makes use of the "id" parameter. */ first_name = (char... (8 Replies)
Discussion started by: Andrewkl
8 Replies

6. Shell Programming and Scripting

Returning the name of function used

Hi All In my script, I can call on several functions. I have a logging function that is called by any of these functions. What I would like is some way of identifying which function I am using and pass this to the log function as some parameter. Is there some built in command or way of... (3 Replies)
Discussion started by: kingpin2502
3 Replies

7. Shell Programming and Scripting

how to pass the values to unix shell from the oracle stored procedure.

Hi i am calling a stored procedure from unix shell like this call test_proc('0002','20100218'); the stored procedure was giving output like this dbms_output.put_line(' processed earlier'); i want to see the output in the unix shell where i called. Thanks barani (6 Replies)
Discussion started by: barani75
6 Replies

8. Shell Programming and Scripting

unix capture oracle function error

Hi, I want to execute an oracle function from unix script so for that I created a sample oracle function as below: create or replace function test_fn(test_date out varchar2) RETURN varchar2 IS BEGIN select to_char(sysdate,'DD-MON-YY') into test_date from dual; return test_date;... (5 Replies)
Discussion started by: dips_ag
5 Replies

9. Programming

Function Returning Pointer

Hi guys. how a functions such fdopen, ... can return pointer? are these functions use static memory(variables)? (6 Replies)
Discussion started by: majid.merkava
6 Replies

10. Shell Programming and Scripting

Returning and capturing multiple return values from a function

Hi I am pretty confused in returning and capturing multiple values i have defined a function which should return values "total, difference" i have used as #!/usr/bin/ksh calc() { total=$1+$2 echo "$total" diff=$2-$1 echo "$diff" } I have invoked this function as calc 5 8 Now i... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies
CFBA2FBA(1)						      General Commands Manual						       CFBA2FBA(1)

NAME
cfba2fba SYNOPSIS
cfba2fba [-options] ifile [sf=sfile] ofile DESCRIPTION
This manual page documents the cfba2fba program. cfba2fba copies a compressed fba file to a fba file. PARAMETERS
ifile input compressed fba dasd file sfile input compressed fba shadow file (optional) ofile output fba dasd file OPTIONS
-v display program version and quit -h display help and quit -q quiet mode, don't display status -r replace the output file if it exists -lfs create single large output file -blks n size of output file SEE ALSO
The programs are documented fully by The Hercules System/370, ESA/390, and z/Architecture Emulator available in /usr/share/doc/her- cules/html. AUTHOR
Hercules was created by Roger Bowler and is maintained by Jay Maynard. Jan Jaeger designed and implemented many of the advanced features of Hercules, including dynamic reconfiguration, integrated console, interpretive execution, and z/Architecture support. This manual page was written by Peter De Schrijver p2@debian.org for the Debian GNU/Linux system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GPL. CFBA2FBA(1)
All times are GMT -4. The time now is 04:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy