The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem while storing sql query value in a variable krishna_gnv Shell Programming and Scripting 1 02-28-2008 07:37 AM
Storing a variable? hoover90 Shell Programming and Scripting 4 01-26-2008 09:39 PM
Storing the output into a variable ravi raj kumar UNIX for Dummies Questions & Answers 7 12-11-2006 09:14 AM
storing output of awk in variable mab_arif16 Shell Programming and Scripting 3 05-07-2006 07:15 PM
Storing values in variable matrixmadhan Shell Programming and Scripting 1 04-01-2005 02:56 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-21-2007
debu debu is offline
Registered User
  
 

Join Date: May 2007
Posts: 10
storing database query in a variable

I am executing a SQL query in Unix Server:
select status,location from user_information where request_id='DS-43720'

In shell script I am writing this query in the below manner:

echo "select status,location from user_information where request_id='DS-43720' ;" >> $directory/info.sql

//(here $directory is my home folder in Unix Server)

echo "EXIT" >> $directory/info.sql

sqlplus -s $sUserId/$sUserPassword@$ORACLE_SID @$directory/info.sql 1>>$directory/info.log 2>>$directory/info.log

Now how do I store those two column values returned in Sql query in a Unix Variable??
  #2 (permalink)  
Old 11-21-2007
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Show us what the output looks like and we can probably come up with something. In the meantime, I'd suggest that you want something like:

Code:
myvariable=`long-sql-command`

Use of awk and cut should be able to split out the data in the columns.

Without one of the redirects (at a guess, you should still redirect STDERR to the log but stop redirecting STDOUT so the calling script can capture it instead).
  #3 (permalink)  
Old 11-22-2007
debu debu is offline
Registered User
  
 

Join Date: May 2007
Posts: 10
can you mention the awk and cut commands format?
  #4 (permalink)  
Old 11-25-2007
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Quote:
Originally Posted by debu View Post
can you mention the awk and cut commands format?
You'd need to show us the output that needs splitting up first sorry
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0