Unable to retrieve data from shell when connected to Oracle


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to retrieve data from shell when connected to Oracle
# 1  
Old 09-10-2012
Unable to retrieve data from shell when connected to Oracle

I am trying to get the data from oracle table to a variable I have tried the below code
Code:
#/usr/bin/sh
        echo " I am in correct loop"
        SPOOL_FILE=/app/scripts/alt.lst
      sqlplus /nolog  <<END_SQL
        connect bindu/bindu@gis
        whenever sqlerror exit failure rollback;
        set serveroutput on
        set termout on
        set trimspool on
        SPOOL $SPOOL_FILE
        select 'SQLCODE' ||'count(*) from altuomlog
        /
      spool off
     EXIT
     END_SQL
     echo " I am in correct loop"
      SQLCODE='cat ${SPOOL_FILE} | grep SQLCODE | awk '{print $2}''
   echo $SQLCODE
      unset EXIT_STATUS
       unset SQL_CODE
     echo "END.. I am in correct loop"

when I ran this code the it got exit from the oracle after completion of the select statement the rest of the shell script is not executed.if I removed the exit statement the in that case the shell is throwing error.

Please advice..

Thanks in advance..
# 2  
Old 09-10-2012
dont give any spaces for the line where you used
Code:
END_SQL

it should be stick to the left side of the editor..
This User Gave Thanks to vidyadhar85 For This Post:
# 3  
Old 09-11-2012
I am able to run the shell.very much appreciated

Could you please let me know what was the error in the below line:
Code:
 SQLCODE='cat $SPOOL_FILE | grep SQLCODE | awk -F    '{print $2}' '

Thanks in advance..
# 4  
Old 09-11-2012
You have it in single quotes, not backticks, therefore you're storing it as a literal string, and not actually running it.

Also, that's a useless use of cat
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 10-02-2012
code for output of a spoolfile through mail

Hi

I want to send the output of a spool file through mail.FYI..the spool file consists of output of a select comand with only 3 columns.The mail should be sent to a list of people .I didn't have a good knowledge on Shell what I can see is that the list of people where added to a variable list and called the mailx command.

Can some one please send me the code how to do this by taking above two consideration

Thanks in Advance
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

2. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

3. SuSE

HELP for Newbie: Unable to run GUI installer (Ubuntu client connected to SLES server)

Hello All, I'm using my Ubuntu 10.04 client connected via SSH to a SuSE Linux server (SuSE Linux Enterprise Server 11 (x86_64) version 11 patchlevel=1). I'm trying to run an install of WebSphere Portal but can't seem to be able to run the GUI installer. Running xclock as root returns this... (7 Replies)
Discussion started by: kartrait
7 Replies

4. Shell Programming and Scripting

Loading data in oracle using shell scripts

Hi , I have a scenario, i have a directory where i receive around 14-15 files at a interval of 20-40 min not fixed, i want to write a unix scripts which invoke sqlldr command to load files into oracle automatically as soon as the file hit the directory. Any help will be appreciated. ... (4 Replies)
Discussion started by: guddu_12
4 Replies

5. Shell Programming and Scripting

why do we need UNIX shell script to load data into Oracle database

Hello everyone, I am new to shell scripting/ loading data into a database. I want to load data into Oracle database using SQL loader. Can some one please explain why do we need unix shell script to load the data into the database? Also can someone please explain what has to be in that script?... (5 Replies)
Discussion started by: new_prog
5 Replies

6. Shell Programming and Scripting

Shell script to export data from Oracle table .

Hi, I want to write a shell script which will export data from oracle table . I don't want to save that data . I want the queries . Right now i am right clicking on the table and clicking on export as to my desktop . Please let me know if any one have any idea . (2 Replies)
Discussion started by: honey26
2 Replies

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

8. Shell Programming and Scripting

Need shell script to extract data from oracle database

shell script (4 Replies)
Discussion started by: frns5
4 Replies

9. Shell Programming and Scripting

Shell Script for Data loading in Oracle

Hi All I am new to unix. I need a shell script to load a datafile in to oracle. I already have a control file, and data file. all I need is if i execute the shell it must load the data using the ctl file to table. Control file : PAY0001.ctl Datafile : mon_grs_det.dat log file :... (3 Replies)
Discussion started by: raghuraja_r
3 Replies

10. UNIX for Dummies Questions & Answers

Retrieve Oracle export to tape

Hi! We have an Oracle db export that was compressed and written to DLT tape directly!- This is from box1 The next step is to restore the contents of the tape into the database on box2. The problem is that there is no DLT tape drive attached to box2. There is a box3 that has the tape drive... (1 Reply)
Discussion started by: sdharmap
1 Replies
Login or Register to Ask a Question