The UNIX and Linux Forums  

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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script needed vpandey Shell Programming and Scripting 3 03-04-2008 05:45 AM
help needed! my first script fcbarcelona1984 Shell Programming and Scripting 1 11-04-2007 08:32 AM
Script needed to FTP a file from sql report to unix server vprevin Shell Programming and Scripting 0 10-30-2007 10:33 PM
please help me how to script atomatic remove file that are not needed sunilnbalar Shell Programming and Scripting 1 08-23-2007 03:30 AM
Script Needed Dastard SUN Solaris 1 03-20-2007 06:54 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-20-2008
Registered User
 

Join Date: Dec 2007
Location: Gotham City
Posts: 55
Help needed in script and sql file

Hi all,
I have a script which takes in sqlfile as argument and executes the sql

execSqlFile()
{
sqlFile=$1
sqlplus -S $DBLOG/$DBPWD@$DBSVR < $sqlFile
}

This works fine if the sql file is plain, simple and pre-defined statment. But i want to have a sql file which itself will take an argument

What do i need to modify in my script?

Please help!
jak
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-20-2008
Registered User
 

Join Date: Mar 2008
Location: Bay Area California
Posts: 63
First you have to embed argument stubs into your script...

mysql.sql might be

select x, z from t where x = $1 and z = $2;

Obviously very simple example...

then just pass arguments to script on command line...

execSqlFile()
{
sqlFile=$1
arg1 = "abc"
arg2 = "def"
sqlplus -S $DBLOG/$DBPWD@$DBSVR < $sqlFile $arg1 $arg2
}

It's that simple...
Reply With Quote
  #3 (permalink)  
Old 03-22-2008
Registered User
 

Join Date: Dec 2007
Location: Gotham City
Posts: 55
Thanks for the help
jak
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:30 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