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: A simple (but stupid) question.

Re: A simple (but stupid) question.

From: Glen E. Siferd <siferd_at_admin.uwex.edu>
Date: Fri, 17 Dec 1999 10:36:56 -0600
Message-ID: <83dor7$bn6$1@news.doit.wisc.edu>


Not at all stupid. One suggestion:

Call this procedure (source: Steven Feuerstein) from your script to drop tables or other objects:

PROCEDURE drop_object

         (type_in IN VARCHAR2, name_in IN VARCHAR2) IS
--
 /* The static cursor retrieving all matching objects */  CURSOR obj_cur IS
  SELECT object_name, object_type
    FROM user_objects
   WHERE object_name LIKE UPPER (name_in)    AND object_type LIKE UPPER (type_in)    ORDER BY object_name;

 /* Handle to the dynamic SQL cursor */  cursor_handle INTEGER;
BEGIN
 /* For each matching object ... */
 FOR obj_rec IN obj_cur
 LOOP
  /* Open a cursor for this next object */   cursor_handle := DBMS_SQL.OPEN_CURSOR;

  /* Construct the SQL statement and parse it in Version 7 mode. */   DBMS_SQL.PARSE
   (cursor_handle,
    'DROP ' || obj_rec.object_type || ' ' || obj_rec.object_name,     DBMS_SQL.V7);   /* Close the cursor for this object */   DBMS_SQL.CLOSE_CURSOR (cursor_handle);  END LOOP;
END drop_object;

"Wm. G. Urquhart" <william_at_devnet-uk.net> wrote in message news:E4p64.3626$PV6.376554_at_news4.usenetserver.com...
> I would like to include the logic in my script to drop a table (for
example)
> if it already exists. How do I do this.

>

> William.
>

> P.S. I did say that it was stupid.
>
>
>
>
>


Received on Fri Dec 17 1999 - 10:36:56 CST

Original text of this message

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