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