Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: TRUNCATE from a stored procedure?

Re: TRUNCATE from a stored procedure?

From: Jonathan Ingram <jingram_at_teleport.com>
Date: 1997/05/25
Message-ID: <3388c9a0.29880786@news.teleport.com>#1/1

On Sun, 25 May 1997 15:15:12 -0400, "Panther" <rollman_at_one.net> wrote:

>If anyone can tell me how this might be accomplished, I'd appreciate it.
This function should do the trick for you:

CREATE OR REPLACE
FUNCTION Truncate_Table (vTableName IN varchar2)

RETURN integer

IS

   iCursorID           integer;
   vCommand            varchar2 (80);
   iReturned           integer;

   xNO_TABLE_NAMED     EXCEPTION;

BEGIN
   IF (vTableName IS NULL) THEN

      RAISE xNO_TABLE_NAMED;
   END IF;    vCommand := 'TRUNCATE TABLE ' ||

               vTableName;
               

   iCursorID := DBMS_SQL.Open_Cursor;
   DBMS_SQL.Parse (iCursorID,

                   vCommand,
                   DBMS_SQL.v7);

   iReturned := DBMS_SQL.Execute (iCursorID);    DBMS_SQL.Close_Cursor (iCursorID);

   RETURN 1; EXCEPTION
   WHEN OTHERS THEN
        RETURN 0;
END Truncate_Table;
/

If not, let me know and we'll try something else.

Jonathan Ingram Received on Sun May 25 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US