I want to run a script with a parameter & then pass the parameter to some sql code in the script. I've spent a long time looking on the web & none of the suggestions I can find works:
Here's a simplified version of the script called test_sql:
When I run this I get:
I have tried one quote, 2 quotes, no quotes, double quotes around &1, I have tried $1 etc etc & you will appreciate that I am now guessing.
Can anyone help me out?
Thanks, Chris
Here's a simplified version of the script called test_sql:
Code:
#!/bin/ksh
##
##
## set oracle variables up
ORACLE_SID=cflive
ORA_NLS10=/cfldbap/oracle/product/10.2.0/nls/data
ORACLE_HOME=/cfldbap/oracle/product/10.2.0
LD_LIBRARY_PATH=/cfldbap/oracle/product/10.2.0/lib
echo ++++++
echo $1
echo ++++++
sqlplus '/ as sysdba' <<EOF
set define off
select '&1' from dual;
EOF
When I run this I get:
Code:
$ ./test_sql param1
++++++
param1
++++++
SQL*Plus: Release 10.2.0.4.0 - Production on Wed Sep 9 16:25:38 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SQL> SQL>
'&
--
&1
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
(/export/home/oracle/scripts/backups)
oracle cflive >
I have tried one quote, 2 quotes, no quotes, double quotes around &1, I have tried $1 etc etc & you will appreciate that I am now guessing.
Can anyone help me out?
Thanks, Chris