【发布时间】:2012-04-06 20:54:49
【问题描述】:
您可以在下面看到我尝试在 sqlplus 上执行的 SQL 脚本模板:
WHENEVER SQLERROR EXIT 1 ROLLBACK
WHENEVER OSERROR EXIT 1 ROLLBACK
BEGIN
-- Doing some Insert
END;
/
INSERT INTO TMP_TABLE VALUES('A', 'B')
COMMIT;
QUIT;
/
此脚本在我的本地系统上的文件 (Test1.sql) 中可用,我通过 Windows 命令行控制台连接到 Oracle 来运行此查询。在 cmd 下输入一行。
C:\Users\myself> sqlplus UNAME/PWD@//DB IP:PORT/SID @C:\Users\Test1.sql
在 SQL 脚本中,我故意没有用分号终止一条语句 (INSERT INTO...)(见上文)。现在,当我按照上述说明运行此脚本时,程序成功运行并打印一条消息:
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Apr 6 16:50:19 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
PL/SQL procedure successfully completed.
Commit complete.
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64
bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
当我在我的 SQL Navigator 工具上运行同一组脚本时,出现以下错误,这是正确的:
[10]:(错误):ORA-00933:SQL 命令未正确结束
我不明白为什么脚本没有报告此错误,而是显示类似“提交完成”的消息。
当我尝试使用 Windows 命令控制台通过 sdlplus 运行相同的脚本时,你能告诉我如何让我的脚本在控制台上抛出此错误吗?
【问题讨论】: