SQLPlus is trying to drop package twice

大兔子大兔子 提交于 2019-12-02 02:19:57

The rules of SQLplus command execution basically are:

  • 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 or BEGIN, collect all the text and do not execute on semi-colons
  • If you encounter a slash (/), execute the collected text.

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.

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.

Some examples will help to understand rules:

  1. Below code will be executed once
begin
  dbms_output.put_line('executed');
end;
/
  1. Below code will not execute (missing semicolon)
begin
  dbms_output.put_line('executed')
end
/
  1. Below code will be executed twice
begin
  dbms_output.put_line('executed');
end;
/
/
  1. Below code will be executed once
select 1 from dual
/
  1. Below code will be executed once
select 1 from dual;
  1. Below code will be executed twice
select 1 from dual;
/
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!