How to Execute Dynamic SQL Statements or DDL Statements in PL/SQL? (Doc ID 1005691.6)

Last updated on JULY 05, 2017

Applies to:

PL/SQL - Version 9.2.0.8 and later
Information in this document applies to any platform.
***Checked for relevance on 03-Dec-2013***

Goal

Suppose that you want to execute a SQL statement within a PL/SQL block, but the  table name or a column name or a value in the WHERE clause is unknown until execution time.  This is known as dynamic PL/SQL.  It is often asked how one can get dynamic  PL/SQL.  
 
Another common question is how can one execute Data Definition Language (DDL) statements.

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms