当程序路径包含空格时,SQL*plus 无法正确标记其命令行参数

发布于 2024-12-05 02:47:39 字数 575 浏览 5 评论 0原文

我通过以下命令行使用 SQL*Plus:

sqlplus user/pw@TNS @test.sql foo

test.sql 的内容如下:

SET VERIFY ON
DEFINE argone='&&1'
SELECT '&argone' FROM dual;
EXIT SQL.sqlcode

结果:

  • 当 SQL*Plus 可执行文件位于 C:\Program Files\Oracle Client\whatever\ 中时sqlplus.exe 然后 &&1 计算结果为 Files\Oracle
  • 当 SQL*Plus 可执行文件位于 C:\Oracle\Client\10.2.xx\bin 中时,&&1 的计算结果为 foo

有没有人遇到过这个问题并且有办法规避它?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

翻身的咸鱼 2024-12-12 02:47:39

您需要在命令行和 define 语句中使用双引号来正确捕获带空格的参数。

脚本:

SET VERIFY ON
DEFINE argone="&&1"
SELECT '&argone' FROM dual;
EXIT SQL.sqlcode

命令行:

sqlplus user/pw@TNS @test.sql "foo bar"

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文