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 > Shell Programming and Scripting
.
google unix.com



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
Using isql in korn shell risk_sly UNIX for Dummies Questions & Answers 2 09-25-2008 10:46 PM
get values from isql query DebianJ Shell Programming and Scripting 3 06-27-2008 06:52 AM
isql query in unix shell script jaydeep_sadaria Shell Programming and Scripting 3 11-14-2007 03:07 AM
compound variable in korn shell ZINGARO Shell Programming and Scripting 5 10-03-2007 10:57 AM
Setting value of Shell variable from within ISQL tipsy Shell Programming and Scripting 3 08-29-2006 07:23 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-09-2009
Cailet Cailet is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 19
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:
  1. Does it matter that there are multiple queries in each file? Do I need to have special formatting within the files to ensure everything processes correctly?
  2. Is there any way to pass in variables for the query statements?

Thanks!
  #2 (permalink)  
Old 02-09-2009
quirkasaurus's Avatar
quirkasaurus quirkasaurus is offline
Registered User
  
 

Join Date: Jan 2009
Location: canton, michigan
Posts: 373
1.) Multiple queries can be separated by semi-colons.

2.) Within the SHELL, you can use this:

Code:

isql << EOF

SELECT some_stuff
  FROM table_some_thing
 WHERE some_field = "$some_input_variable" ;

EOF
  #3 (permalink)  
Old 02-09-2009
Cailet Cailet is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 19
Ok - so I can put multiple queries in my file as long as they all have the semi colon.

since I have a file full of queries, I would want to use the "-i" option. Unless I am missing something, it seems like putting them hardcoded into the script would be way too much. Is there any way for me to pass a variable into the iSql command when it runs the file?
  #4 (permalink)  
Old 02-09-2009
quirkasaurus's Avatar
quirkasaurus quirkasaurus is offline
Registered User
  
 

Join Date: Jan 2009
Location: canton, michigan
Posts: 373
Using my answer to #2.

Substitute a positional parameter like so:

% my_sql_stuff.sh first_arg second_arg

inside the my_sql_stuff.sh:

Code:

isql << EOF

SELECT some_stuff
  FROM table_some_thing
 WHERE some_field = "$1"
   AND something_else = "$2";

EOF
Sponsored Links
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 06:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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