2

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.`
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Vishal Saxena
  • 137
  • 2
  • 2
  • 6

3 Answers3

5

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

Something like:

begin
    execute immediate 'truncate table foo';
end;
/
Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
0

TRUNCATE is DDL (data definition language). You cannot perform DDL from within PL/SQL. That is, you cannot directly but you can through dynamic SQL.

So

Use this : DELETE FROM

Farid
  • 21
  • 4
0

This execution can be included in a procedure

EXECUTE IMMEDIATE ('truncate table name');
--next--
INSERT
    / * + append * /
    INTO table ..
Patrick
  • 1,717
  • 7
  • 21
  • 28