how to use shell variable in isql


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to use shell variable in isql
# 1  
Old 02-09-2011
how to use shell variable in isql

Hi ,

I want to use shell variable in isql.

example..
Code:
$ksh ./sudh.ksh "2041qwer"

sudh.ksh is my script passing the perameter "2041qwer"

Code in my script :
===========
Code:
$SYBASE/$SYBASE_OCS/bin/isql -I$SYBASE/interfaces -S$OTHRSRVR -U$SYBUSER -P$SYBPASS -w 300<<EOF>$HDIR/domm_data.txt

 declare @Query varchar(9)
       select @Query=$1  #($1 is perameter from the script)
       declare @num_records int


Last edited by Franklin52; 02-10-2011 at 03:42 AM.. Reason: Please use code tags
sudhakarpasala
# 2  
Old 02-10-2011
Sure, looks fine. I am more a fan of echo, where you can preview the output easier, and switch quotes to control what is exposed to shell substitution:
Code:
echo ' . . . '"$variable"' . . . ' | isql . . . .

Both are shell built in, << writes a /tmp file, | calls pipe().
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get the output of a ISQL command in a variable?

I am trying to run a query which returns a sum value(a number). I want to get it in a variable so that i can refer to that variable in different places. when i am running the following command variable=`isql -Uuser -Sserver -Ppassword 1> select sum(count(*)) from xyz..abc where clm_id... (2 Replies)
Discussion started by: Sharma331
2 Replies

2. 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

3. Shell Programming and Scripting

How to assign value from isql to UNIX variable

I want output to be assigned to UNIX variables echo "Enter RRS ID: " read rrs isql -SPROD_DDS -USYBUSER -PSYBPASS -b -osfg.out << EOF use sip go set nocount on select issuerId, legalStructTxt, productName, issuerName from sf_product where rrsId = $rrs go EOF (1 Reply)
Discussion started by: JayDoshi
1 Replies

4. Shell Programming and Scripting

Help With isql in shell script

Hello I am not able to get the isql output to temp_res file ... i have tried all the different combinations as shown below, but could not get anywhere .... Please Help isql -S $serv_name -U $usr_name -P $pswd -D $db_name -o temp_res << EOF1 select status from modset where... (1 Reply)
Discussion started by: gkrish
1 Replies

5. 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

6. Shell Programming and Scripting

isql out in shell script

Hi I wrote a script for connecting isql(Sybase database) and stored the SQL output in Unix box. my script: isql -U${USER} -P${PASS} -S${SERVER} <<EOF > $WORK_DIR/out1.log go select convert(varchar(10),sdcurrent,101) from pr_sysdate go exit EOF Unfortunately, the output file not... (5 Replies)
Discussion started by: koti_rama
5 Replies

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

8. UNIX for Dummies Questions & Answers

Using isql in korn shell

Hi all, I have two accounts in a Unix server, the first one uses .tcsh as default shell and the other uses .ksh (korn shell) as default. When I login using the account with .tcsh default, I can use the isql command and connect to our database server. However, when I use the other... (2 Replies)
Discussion started by: risk_sly
2 Replies

9. Shell Programming and Scripting

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. (3 Replies)
Discussion started by: tipsy
3 Replies

10. Shell Programming and Scripting

isql in shell script help

Hello all... i'm trying to execute a shell script through crontab. To run at 8pm on wednesday's The crontab entry: 00 20 * * 3 /u2/dir1/dir2/jobs/p.sh the p.sh file: isql -s claims /u2/dir1/dir3/dir4/a.sql permissions for it are -rwxrwx--x i've confirmed a.sql is in that directory. ... (2 Replies)
Discussion started by: mrviking
2 Replies
Login or Register to Ask a Question