Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: A simple (but stupid) question.
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.
>
>
> > > > >Received on Fri Dec 17 1999 - 10:36:56 CST
![]() |
![]() |