Oracle: DBMS_UTILITY.EXEC_DDL_STATEMENT vs EXECUTE IMMEDIATE

后端 未结 2 1705
情书的邮戳
情书的邮戳 2021-02-05 04:56

Which are the differences between DBMS_UTILITY.EXEC_DDL_STATEMENT and EXECUTE IMMEDIATE?

2条回答
  •  心在旅途
    2021-02-05 05:34

    I realize I am 9 years late to the reply but there is one additional difference.

    dbms_utility.exec_ddl_statement will not execute anything but DDL. If you try to do say an insert, it will not do it. It will also not return an error either so you won't know that you did not insert.

    -- drop table kevtemp1;
    
    create table kevtemp1 (a integer);
    
    insert into kevtemp1 values (1);
    commit;
    
    begin
        insert into kevtemp1 values (2);
    end;
    /
    commit;
    
    begin
       DBMS_UTILITY.EXEC_DDL_STATEMENT('insert into kevtemp1 values (3)');
    end;
    /
    commit;
    
    
    select * from kevtemp1;
    

提交回复
热议问题