Solved

truncate table in a package/proc

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now