I have a query which is like this in a file :
script.sql
select *
from test_table
where name in (&1)
This is an example of query i'm trying to make
and i execute it with a power shell script which is like this :
$names = '''Name1'', ''Name2'''
$params = '"' + $names + '"'
sqlplus -silent $username/$password@$tnsalias "@script.sql" $params
Note that $names has a variable list of names
But then when the script is executed, the parameter get substitute like this :
former : where name in (&1)
new : where name in (Name1)
And of course the SQL throws an error.
Why it substitutes the parameter like this ?
How can i achieve what i want to do, so the first parameter is a list of strings which will be used in the where name in(&1) clause. My goal is that the sql will be
where name in ('Name1', 'Name2')
The SQL is executed on Oracle 11 if that can help.
$namesto be a string. Does sqlplus require literal double quotes to be passed to it? If you did something like$names = '"''Name1'',''Name2''"', then the string would include the surrounding double quotes. You also have a space between the names. Does sqlplus care?&1. I will again fix my question