Setting value of Shell variable from within ISQL


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Setting value of Shell variable from within ISQL
# 1  
Old 08-29-2006
MySQL Setting value of Shell variable from within ISQL

Hi Guys,
Need help. I am using ISQL inside a shell script.
Is there a way to set the value of shell script variable from inside the ISQL code. I do not want to write the results from the SQL to an output file.
Please let me know.

Regards,
Tipsy.
# 2  
Old 08-29-2006
VARIABLE=`isql ...`
# 3  
Old 08-29-2006
Doing this means I have to open a new dedicated ISQL connection just to get a value from DB & set it in the Shell variable.
I already have ISQL code inside the script doing a bunch of functionalities. I believe there is not other option but was hoping that I could do something inside the existing ISQL code. Do let me know.

Thanks.
Tipsy.
# 4  
Old 08-29-2006
I use this kind of logic for Oracle sqlplus:

Code:
typeset IFS=$(echo '\012\001')
set -A ARRAY $(sqlplus ...)
for i in ${ARRAY[@]}
do
    case $i in
        some kind of search criteria) VAR=xyz ;;
        some kind of error code) report_error ;;
    esac
done

This gives you line-by-line control over the output.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Return value inside isql to a shell variable in ksh

Hello, I have a shell script where I am doing an isql to select some records. the result i get from the select statement is directed to an output file. I want to assign the result to a Shell variable so that I can use the retrieved in another routine. e.g. "isql -U${USER} -P${PASSWD} -S${SERVER}... (1 Reply)
Discussion started by: RookieDev
1 Replies

2. Shell Programming and Scripting

setting a shell script variable in awk

The following is part of a larger shell script grep -v "Col1" my_test.log | grep -v "-" | awk '$5 == "Y" {print $1}' instead of printing, can I set set $1 to a variable that the rest of the shell script can read? if $5 == Y, I want to call another shell script and pass $1 as a... (2 Replies)
Discussion started by: guessingo
2 Replies

3. UNIX for Dummies Questions & Answers

how to use shell variable in isql

Hi , I want to use shell variable in isql. example.. $ksh ./sudh.ksh "2041qwer" sudh.ksh is my script passing the perameter "2041qwer" Code in my script : =========== $SYBASE/$SYBASE_OCS/bin/isql -I$SYBASE/interfaces -S$OTHRSRVR -U$SYBUSER -P$SYBPASS -w... (1 Reply)
Discussion started by: sudhakarpasala
1 Replies

4. Shell Programming and Scripting

Probelm setting a variable to $* in C Shell

Trying to put all command line arguments to the script in a variable msgst01 $* does not seem to work set msgst01 = $* (2 Replies)
Discussion started by: kristinu
2 Replies

5. Shell Programming and Scripting

Setting environment variable using shell script

Hi All, I'm trying to write an menu driven program to automate some functions which involve loging to multiple hosts. The hosts can differ for every use, so I thought I would use an config file to get the hostnames. Now I need to set those values in the config file to environment variable to... (6 Replies)
Discussion started by: arun_maffy
6 Replies

6. Shell Programming and Scripting

How to assign record count output of isql to a shell variable ?

isql select count(*) from Table eof How to assign record count output of isql query to a shell variable ? (4 Replies)
Discussion started by: vikram3.r
4 Replies

7. Shell Programming and Scripting

Setting Variable in TCL to be understood by KSH Shell

Hi , I am having one TCL TK script , I am setting some variables in the GUI TK interface set DI 1 set MODELS_PATH /a/d/path but I want to make ksh shell understand the variables when I am running TK script I tried to do like this set a but it is not working ... (1 Reply)
Discussion started by: kshitij
1 Replies

8. Shell Programming and Scripting

Error in setting PATH variable in bash shell

Hi, I am new to shell scripting.I tried adding an entry to the path variable like below export PATH=$PATH:/opt/xxx/bin But am getting an error invalid identifier /opt/xxx/bin Can someone tell me the error above and correct me . Thanks and Regards, Padmini (2 Replies)
Discussion started by: padmisri
2 Replies

9. Shell Programming and Scripting

Setting variable for query using iSql / Korn Shell

Hi All- First time using iSql. I have 4 query files - some have more than 1 line of sql statements After a bit of research it appears I can just use the -i command and specify the input file. Questions: Does it matter that there are multiple queries in each file? Do I need to have... (3 Replies)
Discussion started by: Cailet
3 Replies

10. Shell Programming and Scripting

Setting environment variable on a remote solaris machine using shell script

Hi, I am trying to set environment variable on a remote machine. I want to do it by running a shell script Here's what I am doin rsh <remote-hostname> -l root "cd /opt/newclient; . ./setp.sh" In setp.sh, I have ############################# cd ../newlib; export... (1 Reply)
Discussion started by: eamani_sun
1 Replies
Login or Register to Ask a Question