Solved

truncate table in a package/proc

Posted on 2002-07-17
2
1,754 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 50 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

617 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