![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| ::select statement return value with correct field size:: | ryanW | Shell Programming and Scripting | 10 | 04-23-2009 02:38 AM |
| Oracle Select IN statement | benefactr | UNIX and Linux Applications | 1 | 03-26-2009 04:15 PM |
| Supress ' quotes in a select statement inside Shell Script | mahabunta | Shell Programming and Scripting | 1 | 12-14-2006 06:29 PM |
| Want to use the output of Select statement in Unix script | akhilgoel9 | Windows & DOS: Issues & Discussions | 4 | 05-27-2005 09:52 AM |
| Pipe SQL select statement results to script | houtakker | UNIX for Dummies Questions & Answers | 6 | 10-31-2003 01:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
using SELECT sql statement in shell script
Hi there
I have a database on a remote box and i have been using shell script to insert data into it for example, i could have a script that did this Code:
SN=123456 n=server1 m=x4140 sql="UPDATE main SET hostname='$n',model='$m' WHERE serial='$SN';" echo $sql |/usr/sfw/bin/mysql -h db-server1 -utest TEST however, I now want to be able to issue a SELECT statement (populating some variables with the results) so that i can continue to use them in the script for example if i was to issue Code:
sql="SELECT hostname, model FROM main WHERE serial =$SN" echo $sql |/usr/sfw/bin/mysql -h db-server1 -utest TEST Does anybody know how I get these query results objects into usable variables like this ?? any help on this would be greatly appreciated as I am completely flummoxed |
|
||||
|
thanks vidyadhar85
Unfortunately, I have hundreds of values ill be pulling down from the db, so technically i would have to have a line of code for each one, which isnt ideal but it works and thats great, thankyou incidentally, issuing the "set head off" and the others, is that something I have to do on the server itself as a general setting , or do i integrate it into the query somehow ? i tried Code:
# echo "set head off" | /usr/sfw/bin/mysql -h db-server1 -utest TEST ERROR 1193 at line 1: Unknown system variable 'head' |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|