使用" @@"时出现错误sp2-0310 (双" at"签署)命令

时间:2016-06-08 15:39:28

标签: oracle sqlplus

我有一个类似于

的文件夹结构
/Release_script/
  install.sql
/common_code/
  error_handling.sql
/Reporting/
  fancy_report1.sql
  fancy_report2.sql
  some_code_to_include.sql

install.sql脚本包含行

@../Reporting/fancy_report1.sql
@../Reporting/fancy_report2.sql

fancy_report1.sql和fancy_report2.sql都以

行开头
@@../common_code/error_handling.sql

他们还包括其他/Reporting/个文件,即@@some_code_to_include.sql

正如#34; SQL * Plus用户指南和参考"中记录的那样,@@ (double "at" sign)

  

运行脚本。此命令几乎与@(" at"符号)相同   命令。 它对于运行嵌套脚本非常有用,因为它具有   查找指定脚本的其他功能   与调用它的脚本相同的路径或URL 。只有网址   表格在iSQL * Plus中受支持。

当我在/Release_script/中打开sqlplus并尝​​试运行install.sql时,我收到错误

  

SP2-0310:无法打开文件" ../ common_code / error_handling.sql"

如果我更改fancy_report1.sql对@../common_code/error_handling.sql的引用,则直接从/Reporting/文件夹执行fancy_report1.sql,它可以正常工作。

我应该使用哪些命令从工作目录的起点(即fancy_report1.sql)和从起始点运行命令(即, /Release_script/)?为什么@@命令的行为与@命令完全相同?

为了它的价值:

sqlplus -S /nolog<<EOF
prompt &_SQLPLUS_RELEASE

收率:

1102000100

2 个答案:

答案 0 :(得分:1)

我要说的是你的SQL * Plus版本不喜欢使用@@的相对路径。

此链接:http://www.orafaq.com/wiki/SQL*Plus_FAQ表示“@@ reference不支持相关目录引用,例如@@ dir / file.sql或@@。/ file.sql。”但它适用于我的版本。

我做了与你描述的相同的设置,并使用SQL * Plus运行脚本:版本12.1.0.2.0并且运行正常。 (唯一的区别是我使用error_handling.sql脚本生成文本“COMMON_CODE \ ERROR_HANDLING SCRIPT”。)

我将工作目录设置为Release_script并运行安装文件:

C:\tmp\Release_script>sqlplus <un/pwd> @install.sql

SQL*Plus: Release 12.1.0.2.0 Production on Wed Jun 8 15:16:00 2016

MSG
---------------------------------
COMMON_CODE\ERROR_HANDLING SCRIPT


MSG
---------------------------------
COMMON_CODE\ERROR_HANDLING SCRIPT

答案 1 :(得分:0)

从SQL * Plus文档:

    @@ (double "at" sign)

Runs a script. This command is similar to the @ ("at" sign) command.
It is useful for running nested scripts because it looks for the specified
script in the same path as the script from which it was called.

希望最后一句的后半部分可以成为您问题的线索。 如果是这样,可能需要使用绝对路径名和相对路径名。

不幸的是,我无法在Red Hat Linux 6.7或Windows 7上重新创建该问题。这是我的Windows会话(我只在文件select sysdate - 1 from dual;中使用error_handling.sql):

enter image description here

所以我的建议是使用绝对路径名。

SQL * Plus版本(在Windows 7上):

enter image description here

相关问题