The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
grep unix.com with google



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-29-2009
Registered User
 

Join Date: Jun 2008
Posts: 4
how to - redirect query results to a variable

How can I send the results of a query to a unix variable. I basically want to run a query then do some logic on the results. Trying to redirect the result into a variable I define in the script.

select count(*) as counter from table - nut to redirect the "count" returned from the query into a variable withing the unix script.

Trying this in a teradata bteq script.

Thanks for your help.
  #2 (permalink)  
Old 11-29-2009
Registered User
 

Join Date: Jun 2007
Posts: 13
so you want to run a bteq script which gets the number of rows from a table and then you want to use this number in a variable in a unix shell script?
I think we used to redirect the output of the bteq script into a file and then (within the unix script) read the file into a variable.

There is also a bteq status variable named ACTIVITYCOUNT which saves the number of rows read from any SQL statement. But I suppose this is not what you are looking for. ( see: teradata bteq manual ).

You might also want to check Welcome to The Teradata Forum.
  #3 (permalink)  
Old 11-29-2009
pludi's Avatar
pludi pludi is online now Forum Staff  
Moderator
 

Join Date: Dec 2008
Location: .at
Posts: 2,594
You can save the output of any command to a variable:
Code:
VAR1=$( echo "Hello" )
VAR2=$( ls -l / )

Sponsored Links
Reply

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Oracle Query results to be stored in variables ashokjaysiv Shell Programming and Scripting 4 03-16-2009 10:45 AM
Redirect Postgresql Select Query to Variable uativan Shell Programming and Scripting 3 12-08-2008 04:54 AM
Set shell variables from SQLPLUS query results pranavagarwal UNIX for Advanced & Expert Users 2 09-01-2008 03:26 PM
Redirect Query o/p to variable Swapna173 UNIX for Dummies Questions & Answers 2 08-01-2008 07:48 AM
sql query results in unix shell script skyineyes UNIX for Dummies Questions & Answers 1 06-20-2007 11:56 AM



All times are GMT -4. The time now is 10:56 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