Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: truncate problems in PL/SQL

Re: truncate problems in PL/SQL

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Tue, 19 Sep 2000 06:46:51 +0200
Message-ID: <969340632.18233.0.pluto.d4ee154e@news.demon.nl>

truncate is a ddl statement.
To perform a truncate you either need to use dbms_sql (v7 and 8.0) or execute immediate (8i).
In 8i this would be
execute immediate 'truncate table edge_numbers';

in v7
sql_str := 'truncate table edge_numbers'; cur_handle := dbms_sql.open_cursor;
dbms_sql.parse(cur_handle, sql_str, dbms_sql.native); res := dbms_sql.execute(cur_handle);
dbms_sql.close_cursor(cur_handle);

where res and cur_handle are integer variables.

Hth,

Sybrand Bakker, Oracle DBA

<toadsprocket_at_my-deja.com> wrote in message news:8q6loi$73r$1_at_nnrp1.deja.com...
> I am writing a PL/SQL routine that needs to truncate a summary table
> before starting, the code goes something like this:
>
> DECLARE
> CampaignVar varchar2(80);
> BEGIN
> truncate table edge_numbers;
> select Distinct(Campaign_ID)
> into CampaignVar
> etc etc etc.....
>
> With the truncate I get error PLS-00103 from the parser, I want to
> trunc it on the way in and on the way out of the routine. As soon as I
> pull out the truncate everything works like a charm, can someone say
> ARRGGHH!! :)
>
> Any ideas??
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Mon Sep 18 2000 - 23:46:51 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US