execute immediate truncate table in sqlplus

14,532

You need to add execute before immediate in order to make it to work.

Something like:

begin
    execute immediate 'truncate table foo';
end;
/
Share:
14,532
Vishal Saxena
Author by

Vishal Saxena

Updated on June 04, 2022

Comments

  • Vishal Saxena
    Vishal Saxena almost 2 years

    Why does execute immediate 'truncate table trade_economics'; in a sqlplus script give the following error ?

     BEGIN immediate 'truncate table trade_economics'; END;
                        *
        ERROR at line 1:
        ORA-06550: line 1, column 17:
        PLS-00103: Encountered the symbol "truncate table trade_economics" when
        expecting one of the following:
        := . ( @ % ;
        The symbol ":=" was substituted for "truncate table trade_economics" to
        continue.`