Re: Truncate Table in a PL/SQL Block

From: Srinivasa Rao Vaikuntam <srini_v_at_ix.netcom.com>
Date: 1996/10/21
Message-ID: <54eor0$o1i_at_sjx-ixn6.ix.netcom.com>#1/1


In <3268FFDF.23BA_at_realsoftware.be> Huijbrechts Rolf <huybrecr_at_realsoftware.be> writes:
>
>Hi,
>
>I need to delete all rows in a fast way in a PL/SQL block ? It is an
>all-or-nothing operation so the changes should not be registered in
 the
>rollback segments.
>
>I tried to issue a TRUNCATE TABLE but this is not supported in a
 PL/SQL
>block for Oracle V7.2.
>
>How can help me out on this one ?

Try using dynamic SQL, i.e. DBMS_SQL. DBMS_SQL allows you to use DDL statements in PL/SQL.

for eg:
create procedure trun_tbl as

    curs number;
    stmt varchar2(300);
begin

    curs := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(curs,'TRUNCATE TABLE XYZ',dbms_sql.v7);     DBMS_SQL.EXECUTE(curs);
end;

>
>Much appriciated,
>
>Rolf Huijbrechts
>REAL SOFTWARE
>All opinions expressed are mine and not those of my employer.
>-------------------------------------------------------------
>email : huybrecr_at_realsoftware.be or 101505.533_at_compuserve.com
>website: http://www.realsoftware.be/
>-------------------------------------------------------------
Received on Mon Oct 21 1996 - 00:00:00 CEST

Original text of this message