The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing a variable inside a variable to a function KingVikram UNIX for Dummies Questions & Answers 2 01-14-2008 04:28 PM
passing variable to my script aladdin UNIX for Dummies Questions & Answers 5 06-18-2007 06:34 AM
Passing a variable into an awk script Khoomfire UNIX for Advanced & Expert Users 5 09-05-2006 05:44 AM
variable passing to sed Manish Jha Shell Programming and Scripting 2 08-18-2006 08:54 AM
Variable passing whugo UNIX for Dummies Questions & Answers 2 01-25-2006 02:56 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-30-2007
kamitsin's Avatar
Registered User
 

Join Date: Nov 2006
Location: /dev/null
Posts: 174
passing value to a variable in a SQL

Hi Folks,

This is a small chunk of the bigger problem which i am facing and some help here will help me resolve the rest of the issue.

Problem is that i need to pass the value of a variable from a shell script to a SQL query (infact a lot of SQL's)

i have the following solution but somehow i don't like this solution because this will lead to some major changes (additional lines) in my already too big script.

Code:
echo "enter the date"
read today
echo "select * from informix.table" > abc.sql
echo "where t_date < $today - INTERVAL(5) MONTH TO MONTH" >>abc.sql
I hope am clear in describing the problem, if not please let me know.
A quick help will be very much appreciated.

Cheers,
K

Last edited by kamitsin; 08-30-2007 at 10:29 AM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-30-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,502
Can you not use a here document?
Reply With Quote
  #3 (permalink)  
Old 08-30-2007
kamitsin's Avatar
Registered User
 

Join Date: Nov 2006
Location: /dev/null
Posts: 174
its an alternative but i am searching for a method which can pass the variable from shell script to the Sql's (have a lot of SQL's using the same variable 'current date' but doing different tasks and using a here document will make the script messy)
Reply With Quote
  #4 (permalink)  
Old 08-30-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,502
*I do not know Informix

But. In Oracle you can group dozens of sql statments into one single script file. They execute sequentially. But you execute the script just once.

*disclaimer
Reply With Quote
  #5 (permalink)  
Old 08-30-2007
Registered User
 

Join Date: Apr 2005
Location: Bowling Green, KY
Posts: 1
I am not sure if this helps, but I pass vars from ksh script to oracle sql scripts using the following....

sqlplus -s $DBUSER/$DBPASS @my.sql > output.txt $SHELLVAR;

Then from within my.sql file I reference the input var with '&1'.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0