PLS-00103: Encountered the symbol “CREATE” when expecting

PLS-00103: Encountered the symbol “CREATE” when expecting

If you want to use DDL statement in PL/SQL Blocks then you can do not write directly DDL Statement.
You have to use the Dynamic SQL Syntax for executing the DDL Statement.

Error:

SQL> begin
2 create table test_bkp1 (id number);
3 end
4 /
create table test_bkp1 (id number);
*
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
( begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge

Solution:
Donot use DDL directly in PL/SQL blocks. Use the DDL Statements with Dynamic SQL as follows.

BEGIN
EXECUTE IMMEDIATE 'create table TEST_BKP1 (id number, column_value varchar2(100))';
END;
/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.