开发者

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 to Files\Oracle.
  • When SQL*Plus executable is in C:\Oracle\Client\10.2.xx\bin then &&1 evaluates开发者_开发知识库 to foo.

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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜