Why can't I write DDL directly after a PLSQL anonymous block?

社会主义新天地 提交于 2019-12-02 16:51:37

问题


I have the following simple script.

declare
begin
  null;
end;

create table &&DB_SCHEMA..test_table (
   test_column varchar(20)
);

Executing it ends with the following error

ORA-06550: line 6, column 1:

PLS-00103: Encountered the symbol "CREATE"

  1. 00000 - "line %s, column %s:\n%s"

*Cause: Usually a PL/SQL compilation error.

*Action:

Can't I use the DDL directly after an anonymous block? Am I forced to do it with EXECUTE IMMEDIATE inside the anonymous block?


回答1:


You are simply missing a '/':

SQL> declare
  2  begin
  3    null;
  4  end;
  5  /

PL/SQL procedure successfully completed.

SQL> create table create_test_table (
  2     test_column varchar(20)
  3  );

Table created.

Here you find something more.



来源:https://stackoverflow.com/questions/39588312/why-cant-i-write-ddl-directly-after-a-plsql-anonymous-block

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!