SQLPlus尝试两次删除软件包 [英] SQLPlus is trying to drop package twice
问题描述
在SQLPlus中执行脚本时,我遇到了一个问题:
While executing scripts in SQLPlus I've encountered a problem:
script.sql包含以下几行
script.sql contains the following lines
@some_pkg.pks
@some_pkg.pkb
drop package some_pkg;
/
致电
> sqlplus用户/密码@dbname @ script.sql
以下消息在控制台中:
Package created.
Package body created.
Package dropped.
drop package some_pkg;
*
ERROR at line 1:
ORA-04043: object SOME_PKG does not exist
请解释一下这里发生的事情.好像包裹被丢了两次.有可能避免该错误吗?
Please, explain what's happening here. Looks like the package is being dropped twice. Is it possible to avoid the error?
推荐答案
SQLplus命令执行的规则基本上是:
The rules of SQLplus command execution basically are:
- 遇到分号时,请执行当前文本.因此,如果一行不以分号结尾,则将继续收集当前文本.
- 如果遇到
DECLARE
或BEGIN
,请收集所有文本,不要使用分号执行 - 如果遇到斜线(
/
),请执行收集的文本.
- Execute the current text when you encounter a semi-colon. Thus if a line doesn't end with a semi-colon, the current text continues to be collected.
- If you encounter
DECLARE
orBEGIN
, collect all the text and do not execute on semi-colons - If you encounter a slash (
/
), execute the collected text.
所以在您的情况下,分号和斜杠都执行DROP
语句.
So what happens in your cases is, that both the semi-colon and the slash execute the DROP
statements.
要解决此问题,请删除斜杠.
To fix it, remove the slash.
仅当您有一个PL/SQL块(始终带有END
语句)时,才需要斜杠.将分号用于其他所有内容.
You only need the slash if you have a block of PL/SQL, which always with an END
statement. Use semicolons for everything else.
注意:以上规则已简化.实际上更复杂.
Note: the above rules are simplified. It's more complex in practice.
这篇关于SQLPlus尝试两次删除软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!