Visit Our UNIX and Linux User Community

return code from oracle

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting return code from oracle
# 1  
Old 01-29-2002
return code from oracle

I am writing a unix script that logs into oracle and does a count on a table. I want to return that count to my unix script. this is my script:


typeset retcode;

sqlplus -s <<-EOSQL
variable ret_val number;
select count(*) into :ret_val from ofcr_codes;
exit :ret_val
print "retcode is ${retcode}"
return 0

The retcode is coming up as zero. the retcode should equal 1100, the number of records in the ofcr_codes table. What am I doing wrong?
# 2  
Old 01-29-2002

I'm not sure what your doing wrong, I had the need to do something similiar and instead of manipulating the exit code you could do something like this: note the ticks surrounding the sqlplus and EOF ```


qty=`sqlplus -s $DBLOGIN < < EOF
set head off
set pagesize 0
select count(*)
from ofcr_codes;

echo "The Qty is $qty"
# 3  
Old 01-29-2002
or this seemed to work for me, take the spaces out before < EOSQL


sqlplus -s username/pass < < EOSQL
select count(*) into :ret_val from ofcr_codes;
exit :ret_val
echo "retcode is ${retcode}"
# 4  
Old 01-29-2002
Computer Thanks

Thanks the first response worked for me.

qty=`sqlplus -s $DBLOGIN < < EOF
set head off
set pagesize 0
select count(*)
from ofcr_codes;

The second one didn't though. I appreciate your help.

Previous Thread | Next Thread
Test Your Knowledge in Computers #356
Difficulty: Medium
ibfawk is a very small, function-only, reentrant, embeddable interpreter written in PHP.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getting return value from oracle function

So, in Oracle (11gR2) on aix I have a function like: CREATE OR REPLACE function COMMON.t2(var1 in varchar2, vari in number,var2 in out number) return number as begin insert into korisnik_temp(kor_inicia, kor_opisno) values(1, var1); var2:=0; return var2; exception when... (12 Replies)
Discussion started by: bongo
12 Replies

2. HP-UX

return code from oracle to unix script

Hi I'm writing a shell script that connects to oracle database and fires query to check the availability of data in a table. In case of no data found then what will be the return code and how to handle in that in variable. Kindly provide with an example for better understanding... Thanks... (1 Reply)
Discussion started by: ksailesh
1 Replies

3. UNIX and Linux Applications

Oracle return codes?

Having searched high and low through Oracles documentation, I came to think that they're very scripting-averse, as there's (apparently) no list of possible return/exit codes for their various command line utilities. Is anyone here in possession of such a list, or knows where to find one? It... (16 Replies)
Discussion started by: pludi
16 Replies

4. UNIX for Dummies Questions & Answers

Return value from oracle to unix shell

Hi , i have written a shell scipt to call a procedure and get the value back from procedure.But i am facing the issue like #!/bin/sh returnedvalue=`sqlplus -s userid/pass<<EOF set serveroutput on; exec pass($1) set serveroutput off; EXIT; EOF` flag=`echo $returnedvalue ` echo "$flag"... (2 Replies)
Discussion started by: ravi214u
2 Replies

5. UNIX for Dummies Questions & Answers

to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's

Hi All, Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'. I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
Discussion started by: manas6
0 Replies

6. Shell Programming and Scripting

ORACLE return a function to Solaris

Guys, Im have this problem and I do not know what to do anymore: cod=`sqlplus -s ${DATABASE} << EOF set heading off feedback off verify off select max(eventid) from events; exit EOF` sed "s/CODEVENTID/${cod}/" c.ctl Abova What Ive done. The CODEEVENTID is already set into a... (1 Reply)
Discussion started by: Rafael.Buria
1 Replies

7. Shell Programming and Scripting

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=$?... (1 Reply)
Discussion started by: Vikas Sood
1 Replies

8. Shell Programming and Scripting

Store return code of shell script in oracle table

Hi friends, I have to do the following things : 1) there should be a shell script returning the returning the return code of the script. and i have to add some more details like on which machine is has run , at what time and other details and then using plsql i have to add a row to Oracle... (3 Replies)
Discussion started by: sveera
3 Replies

9. UNIX for Dummies Questions & Answers

Get Oracle fuction return value in a variable

Hi All, :confused: I have the following code. var=' ' sqlplus user/pass@DB <<EOF whenever sqlerror exit 1 select package.func() into $var from dual; EOF echo $var But, this code does not work to display the value returned by the oracle function. Do we have to bind variables before... (3 Replies)
Discussion started by: rahulrathod
3 Replies

Featured Tech Videos