Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Passing String Arguments to SQL*Plus from a Unix Shell
[...]
> I need to pass arguments containing the SQL string delimiter "'" to
> sqlplus from a shell script, e.g.:
>
> sqlplus user/pass @my.sql $1
>
> where $1 should be like "'1','2','3'", so that a SQL statement WHERE
> clause within the script can be modified like this:
>
> define inlist=&1
> ...
> SELECT something FROM mytable
> WHERE something NOT IN ( &inlist );
>
> -->
> WHERE mycol NOT IN ( '1','2','3' );
[...]
$ cat my.sql
set echo on
define inlist=&1
SELECT null FROM dual
WHERE dummy NOT IN ( &inlist );
exit
$ cat run.sh
sqlplus -s / as sysdba @my.sql<<!
"$1"
!
$ ./run.sh "'1','2','3'"
Enter value for 1: old 2: WHERE dummy NOT IN ( &inlist )
new 2: WHERE dummy NOT IN ( '1','2','3' )
N
-
Dimitre
-- http://www.freelists.org/webpage/oracle-lReceived on Thu Mar 29 2007 - 06:41:12 CDT
![]() |
![]() |