Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: using truncate in oracle7 procedures
You have to make sure you have the proper rights as the other people pointed out. Here is a function I use. This function handles tables with synonyms. No warranties, etc... Use at your own risk.
FUNCTION TruncTab
(TableIn VARCHAR2,
ConfirmIn BOOLEAN := TRUE)
RETURN BOOLEAN IS
CursorId INTEGER;
ReturnValue INTEGER;
TableOut all_synonyms.table_name%TYPE;
TableOwner all_synonyms.table_owner%TYPE;
BEGIN
Stack.Push('User_Util.TruncTab');
IF ConfirmIn THEN
CursorId := dbms_sql.open_cursor;
dbms_sql.parse(CursorId, 'TRUNCATE TABLE '||TableIn,
dbms_sql.v7);
TableOwner||'.'||TableOut, dbms_sql.v7);
Stack.Push('The '||TableIn||' table or view does not exist.');
RETURN FALSE;
WHEN aic_err.no_privilage THEN
dbms_sql.close_cursor(CursorId);
-- debug.out('You do not have rights to truncate table '||