SQL*plus does not tokenize its command-line arguments properly when the program path contains spaces
I am using SQL*Plus with the following command line:
sqlplus user/pw@TNS @test.sql foo
The contents of test.sql
follow:
SET VERIFY ON
DEFINE argone='&&1'
SELECT '&argone' FROM dual;
EXIT SQL.sqlcode
Results:
- When SQL*Plus executable is in
C:\Program Files\Oracle Client\whatever\sqlplus.exe
then&&1
evaluates toFiles\Oracle
. - When SQL*Plus executable is in
C:\Oracle\Client\10.2.xx\bin
then&&1
evaluates开发者_开发知识库 tofoo
.
Did anyone encounter this problem and had a way to circumvent it?
You'll need to use double quotes at both the command line and the define
statement to properly capture the arguments with spaces.
Script:
SET VERIFY ON
DEFINE argone="&&1"
SELECT '&argone' FROM dual;
EXIT SQL.sqlcode
Command line:
sqlplus user/pw@TNS @test.sql "foo bar"
精彩评论