Computing.Net > Forums > Unix > Prob Assign Row count to a variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Prob Assign Row count to a variable

Reply to Message Icon

Name: iam2001
Date: July 11, 2007 at 12:57:46 Pacific
OS: Unix
CPU/Ram: N/A
Product: N/A
Comment:

Is it possible to use a shell script to login to a database (using Teradata), run a query and assign the query result to a local variable defined in the shell?
I know it's possible to run teradata SQL through a shell script if teradata is installed on the machine but what I want to do is to assign a value to a variable while at the SQL prompt.

Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: July 11, 2007 at 14:33:37 Pacific
Reply:

Using command substituition, it's possible to assign the contents of any valid unix command - including shell scripts - to a shell variable. Using the Bourne shell, it's

# that's the back tic
a=`echo 1`

or if you are using korn or bash type shells:

b=$(echo 2)



0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Prob Assign Row count to a variable

Assign to a Variable www.computing.net/answers/unix/assign-to-a-variable/4408.html

assigning a variable to a script www.computing.net/answers/unix/assigning-a-variable-to-a-script/5566.html

assign two commands to a variable. www.computing.net/answers/unix/assign-two-commands-to-a-variable/7903.html