LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 09-18-2008, 12:36 PM   #1
atulsh
LQ Newbie
 
Registered: Sep 2008
Posts: 2

Rep: Reputation: 0
How to store SQL output in a variable


Hi,

I am writing a script which has the following SQL query:-
echo -e "select count(*) from aetbs_process_progress where status !='S'and PROCESS!='MarkEoti' and STARTTIME='$DATE1'" >> $PGM1

I am running this query as follows in the later part of script.

sqlplus $ORACLE_USER/$ORACLE_PASSWORD @$PGM1

How can I store the output of @$PGM1 in a variable and match it in the if condition?

Thakns,
Atul
 
Old 09-18-2008, 01:22 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

You can use back-quotes (any shell) or "$()" (Linux BASH), e.g.
Code:
  A=`echo abc`
  echo $A
Quote:
abc
A=$(echo def) echo $A
Quote:
def
In your case, just substitute "sqlplus" for the "echo abc" in my example. Here are a couple of links:
http://www.linuxtopia.org/online_boo...ommandsub.html
http://rand-mh.sourceforge.net/book/mh/comsub.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! SQL User Variable doesn't store decimals when Variables are Reset farmerjoe Programming 1 07-22-2008 07:45 PM
Bash store last line from displayed text output in a variable carl0ski Programming 1 01-16-2007 03:38 AM
using > to store output student04 Linux - General 2 01-21-2005 07:51 PM
Best practices on making an environmental variable to store email addresses for each adseligman Linux - General 1 12-27-2004 04:53 AM
Store PATH variable permanently Skute Linux - Software 8 01-15-2004 04:05 PM


All times are GMT -5. The time now is 05:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration