How to fix the Oracle error PCC-02206: Host variables are not permitted within a DDL statement?

In this post, you’ll learn more about the Oracle ErrorPCC-02206: Host variables are not permitted within a DDL statement with the details on why you receive this error and the possible solution to fix it.

Oracle Error Description

PCC-02206: Host variables are not permitted within a DDL statement

Reason for the Error PCC-02206: Host variables are not permitted within a DDL statement

Cause: A Data Definition Language statement cannot use host variables. For example, the statement CREATE TABLE :table_name (c1 char(10)); is illegal, because the name of the table in a CREATE TABLE statement cannot be represented using host variable.

How to fix the Error PCC-02206: Host variables are not permitted within a DDL statement ?

You can fix this error in Oracle by following the below steps

Action: Use dynamic SQL to create the names of database objects (tables, views, columns, etc.) at runtime. See the Programmer’s Guide to the Oracle Precompilers, Release2.2 for information about dynamic SQL.