Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to truncate table in PL/SQL

Status
Not open for further replies.

dkwong

MIS
Dec 27, 2001
76
CA
I want to use the TRUNCATE table command within a PL/SQL stored procedure, but I notice that it raises a compile error (Encountered the symbol "TABLE" when expecting one of
the following...). According to one source, he says ddl statements are not allowed in PL/SQL and "in Oracle 8 there is a distinct package to do that, and that ought to be documented in the Application Developers Guide." I can't seem to find it in the guide. Does anybody know how to run a truncate command in a stored procedure? I'm trying to do: TRUNCATE TABLE t_project;
 
If you have Oracle 8i, you can do this with an "execute immediate" statement, which is not available in Oracle 8.0.6 or earlier releases.

DECLARE
TRUNCATE_STMT VARCHAR2(100) := 'TRUNCATE TABLE t_project';
BEGIN
EXECUTE IMMEDIATE TRUNCATE_STMT;
END;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top