Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

truncate table in a package/proc

Posted on 2002-07-17
2
Medium Priority
?
1,756 Views
Last Modified: 2012-05-05
What rights do I have to grant to a user to truncate a table in a package?

I have TRUNCATE TABLE table_name in a proc inside of a package. When I try to compile it, I get an error:

LINE/COL ERROR
-------- -----------------------------------------------------------------
363/12   PLS-00103: Encountered the symbol "TABLE" when expecting one of
         the following:
         := . ( @ % ;
         The symbol ":= was inserted before "TABLE" to continue.
0
Comment
Question by:jflemin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
Mark Geerlings earned 200 total points
ID: 7160318
The "truncate table" command and all other DDL statements, are not supported directly in standard (static) PL\SQL.  You can use those statements in dynamic PL\SQL if the user either is the owner of the table, or has the appropriate privilege(s).  If you have Oracle8.1.5 or higher, you can use the "execute immediate..." syntax for dynamic PL\SQL.  If you have an older version, you need the slower and more complex syntax of the procedures/functions in the dbms_utl package.

Here is an example from one of my procedures to do a truncate using "execute immediate":
  execute immediate ('truncate table disabled_triggers');

Note that this works if the PL\SQl procedure is in the same schema as the table owner.  Otherwise the procedure owner may need the "alter any table" system privilege and that is not a privilege you want many users to have.
0
 
LVL 1

Author Comment

by:jflemin
ID: 7160342
I figured this out at the same time that you answered the question. It works. Thanks for your help!!!
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question