Quantcast
Channel: Question and Answer » oracle
Viewing all articles
Browse latest Browse all 717

Why can't we write ddl statement directly into the PL/SQL block

$
0
0

Why can’t we write ddl statements directly in PL/SQL block, for example when i write

CREATE OR REPLACE PROCEDURE test IS
BEGIN
    truncate table table_name; // error
END test;
/

But,

CREATE OR REPLACE PROCEDURE test IS
BEGIN
    execute immediate 'truncate table table_name'; // works fine
END test;
/

Why second one executed successfully ?


Viewing all articles
Browse latest Browse all 717

Trending Articles