DOS/sqlplus“句柄无效”错误?
我有以下批处理脚本:
sqlplus ms/ms@orcl < drop.sql
sqlplus ms/ms@orcl < create.1.0.sql
当我双击 Windows 资源管理器中的 bat 文件并运行它时,它工作得很好。
但是,当我在 DOS 提示符下键入命令名称时,出现错误:
C:\>create.bat
C:\>sqlplus ms/ms@orcl 0<drop.sql
The handle is invalid.
C:\>sqlplus ms/ms@orcl 0<create.1.0.sql
The handle is invalid
有什么想法吗?
更新:更改为使用 @
而不是 <
。这可以解决错误,但现在脚本仅执行第一个文件,然后让您处于 SQL>
提示符处。要执行第二个文件,您必须在提示符处键入 exit
,然后第二个文件才会运行。不确定如何让这两个文件都执行。 ??
I have the following batch script:
sqlplus ms/ms@orcl < drop.sql
sqlplus ms/ms@orcl < create.1.0.sql
This works fine when I double click on the bat file in Windows Explorer and run it.
But when I type the command name from the DOS prompt I get an error:
C:\>create.bat
C:\>sqlplus ms/ms@orcl 0<drop.sql
The handle is invalid.
C:\>sqlplus ms/ms@orcl 0<create.1.0.sql
The handle is invalid
Any ideas?
Update: Made the change to use @
instead of <
. This gets around the error but now the script only executes the first file and then leaves you at the SQL>
prompt. To get the second file to execute you have to type exit
at the prompt, then the second file runs. Not sure how to get both files to execute. ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您希望 SQL*PLUS 执行脚本,比命令行重定向更好的方法是 @ 语法:
另请阅读 @@ 语法,您可以使用它从目录中的另一个 .sql 脚本执行 .sql 脚本。同一目录。
If you want SQL*PLUS to execute a script, a better way than command-line redirection is the @ syntax:
Also read up on the @@ syntax, which you can use to execute a .sql script from another .sql script in the same directory.
我最终编写了一个 python 脚本来运行 sql plus,然后退出它来解决这个问题。我还没有找到任何方法来解决这个限制。尽管如果您按照建议使用
@@
,则只需处理该问题一次。您只需运行第一个脚本中的第二个脚本即可。I ended up writing a python script to run sql plus and then exit it to get around this issue. I have yet to find any way around that limitation. Although you would only have to deal with the issue once if you use
@@
as was suggested. You would just have to run the second script from the first script.