Getting value from oracle to unix shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting value from oracle to unix shell
# 1  
Old 07-17-2009
Getting value from oracle to unix shell

All,

I am using Sun Solaris and Oracle 10g.
I have a simple shell script returning a value.

Code:
#!/usr/bin/ksh

dummyvar=`sqlplus -s '/as sysdba' <<END
set feedback off;
set verify off;
set serveroutput on;
select num from scott.num1;
END`
echo $dummyvar

For the above script - i am getting value as below
Code:
NUM --------- 16-APR-09

i.e, i am getting field name and value.

I don't want NUM-------- . I just want 16-APR-09.

Can someone help me out.

Next time use CODE-tags when posting code, data or logs to enhance readability and to keep formatting like indention etc., ty.

Last edited by zaxxon; 07-17-2009 at 01:37 AM.. Reason: code tags
# 2  
Old 07-17-2009
Add following line at the end before the echo:
Code:
dummyvar=`echo "$dummyvar"| cut -d" " -f3`


Last edited by zaxxon; 07-17-2009 at 02:35 AM.. Reason: typo in text, not in code
# 3  
Old 07-17-2009
Zaxxon,

I used your code, still i am getting the same result.
# 4  
Old 07-17-2009
Have you tried deactivating the header in SQL*Plus?
Code:
set head off

# 5  
Old 07-17-2009
If your output is the echo of your variable, then it should be like this:
Code:
$> dummyvar="NUM --------- 16-APR-09"
$> dummyvar=`echo "$dummyvar"| cut -d" " -f3`
$> echo $dummyvar
16-APR-09

# 6  
Old 07-17-2009
Quote:
Originally Posted by pludi
Have you tried deactivating the header in SQL*Plus?
Code:
set head off

Now it is working with "Set head off"

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Oracle cursors in UNIX shell scripting

Hello, I need to get all the members information from an oracle table whose flag value is enabled. Later on i need to perform several computation based upon the flag value and other columns. For example, Member ID Flag Frequency date 1 ... (2 Replies)
Discussion started by: Krishraj
2 Replies

2. UNIX for Advanced & Expert Users

Use of Oracle pl/sql in UNIX shell script

Hi, I have basic knowledge on how to write pl/sql code inside shell script. I am looking for more advance thing. Is there any book for that which can just talk about how to write more advance plsql code inside shell script. Please help Thanks!!!!!! (1 Reply)
Discussion started by: diehard
1 Replies

3. Shell Programming and Scripting

Need to access Oracle DB with shell/perl script in Unix

Hi, We need to access Oracle DB with shell/perl script in Unix. Is Oracle client needed in Unix for this. I have seen threads which tell abt using SQL plus to access Oracle tables. Can we access DB without SQL PLus installation using scripts in UNix like we access DB using jar files in Java .... (1 Reply)
Discussion started by: justinacc
1 Replies

4. Shell Programming and Scripting

How to fetch data from oracle in unix shell script

Hi, How to fetch data from oracle database in unix shell scripting. list=`sqlplus -s ds_user/dsuser@EMI <<EOF set feedback off set serveroutput on set heading off set pagesize 0 set tab off select IP_ID from table / exit EOF` The output is not what i expected.I need output in... (4 Replies)
Discussion started by: Anusha_Reddy
4 Replies

5. Shell Programming and Scripting

Calling oracle package Unix from shell scripts.

Hi, Can anyone tell me how to call a oracle package from a Unix shell script? I want to pass some input parameters to package and it will return me the output which I want to use further in my shell script. I want to know the way to capture the output values in my shell script. Please send some... (1 Reply)
Discussion started by: anil029
1 Replies

6. UNIX for Dummies Questions & Answers

Help Passing An Oracle parameter to a unix shell.

I have an Oracle concurrent program that I'm passing a parameter to a unix shell script. An example value of the Oracle parameter is PO_TOP. The Oracle parameter represents the unix env var PO_TOP, meaning, on the unix side there is env var called PO_TOP (ex value: /oradev/apps/po/11.0.3/). My... (7 Replies)
Discussion started by: Mark_Wright
7 Replies

7. 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

8. Shell Programming and Scripting

UNIX shell scripting for retrieving from oracle

Hello folks, Please find the below code:(sample5.sh -> filename) echo "Selecting dat afrom Cause code" echo "set appinfo Causecode $preamble set serveroutput on size 10000 select * from RMI003_CAUSE_CODE /" | sqlplus -S $username@$hoststring/$password >> test2.dat When i tried executing... (5 Replies)
Discussion started by: sundar_ravi4
5 Replies

9. UNIX for Advanced & Expert Users

Connecting to Oracle through unix shell scripts

Hi, Can some one help me in connecting to oracle through unix shell scripts with examples. Regards Narayana Gupta (1 Reply)
Discussion started by: guptan
1 Replies

10. UNIX for Dummies Questions & Answers

Unix + oracle doubt....involving shell script

....does the dbms_output.put_line work inside unix shell script? i mean this is to be inside the sqlplus connection as follows!! sqlplus -s $UP <<EOJ .. .. .. dbms_output.put_line ('Insertion procedure failed for UPC BC : ' || wk_key_value || ' Sqlcode: ' || SQLCODE || ' Error... (2 Replies)
Discussion started by: mexx_freedom
2 Replies
Login or Register to Ask a Question