The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
storing result of a command in variable eltinator Shell Programming and Scripting 1 04-17-2008 08:09 PM
echo command result umen UNIX for Dummies Questions & Answers 2 11-10-2005 08:39 AM
FTP command result nymus7 IP Networking 1 08-08-2005 05:01 PM
find command not returning any result rraajjiibb UNIX for Advanced & Expert Users 4 07-23-2004 05:05 PM
Interpretting the result of TOP command sanjay92 UNIX for Dummies Questions & Answers 2 09-21-2001 05:50 PM

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 07-23-2008
hern14 hern14 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 22
Grabbing result of sql command

Hi guys,

Is there a way a script can run an SQL statement and dump the results into a variable which can then be used later in the script?

Thanks.
  #2 (permalink)  
Old 07-23-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
Try this:
Code:
TABLE_NAME=sometable
USER_NAME=someuser
IP_ADDR=localhost
PASSWORD=somepassword

somevar=`echo "select * from <table_name> where <condition>" | mysql -h $IP_ADDR -u $USER_NAME -p$PASSWD $TABLE_NAME `

echo $somevar
  #3 (permalink)  
Old 07-23-2008
hern14 hern14 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 22
Thanks for the help..

I get the following error:

mysql: not found.

I am using Unix on AIX platform, bin/sh script, and DB2 database.
  #4 (permalink)  
Old 07-23-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
That was for a mysql database.

Try to Google: db2 shell query
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 02:51 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