0

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?

Community
  • 1
  • 1
Jagger
  • 10,350
  • 9
  • 51
  • 93
  • Why DDL specifically? You can't do _anything_ without terminating the block. – William Robertson Sep 20 '16 at 09:36
  • Quite a rookie when it comes to PL/SQL therefore I did not know about this magical slash. – Jagger Sep 20 '16 at 09:38
  • The slash isn't really part of PL/SQL - it'll depend on the client app. The point is that `select` wouldn't have worked either, or `insert`, `update`, `delete` etc. – William Robertson Sep 20 '16 at 09:39
  • I agree, it is just that I have had this problem on this specific DDL, I do not oppose to the fact that it does not work with DML either. :) – Jagger Sep 20 '16 at 11:19

1 Answers1

9

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.

Community
  • 1
  • 1
Aleksej
  • 22,443
  • 5
  • 33
  • 38