Search notes:

ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML

create or replace function exec_immediate(stmt clob) return clob as
begin

    execute immediate stmt;
    return stmt;

end exec_immediate;
/
The following select statement throws a ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML error message:
select
   exec_immediate('create table tq84_test(a number)')
from
   dual;
Compile the function with pragma autonomous_transaction to be able execute the function.
create or replace function exec_immediate(stmt clob) return clob as
    PRAGMA AUTONOMOUS_TRANSACTION;
begin

    execute immediate stmt;
    return stmt;

end exec_immediate;
/

See also

ORA-14551: cannot perform a DML operation inside a query
ORA-06519: active autonomous transaction detected and rolled back
Other Oracle error messages

Index