Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SQL> create table sjh (x number);
SQL> create index sjh_idx on sjh(x);
SQL> select index_name from dba_indexes where table_name = 'SJH';
INDEX_NAME
------------------------------
SJH_IDX
SQL> exec drop_obj('index','sjh_idx')
SQL> set feedback on
SQL> select index_name from dba_indexes where table_name = 'SJH';
no rows selected
SQL> set feedback off
SQL> exec drop_obj('index','sjh_idx')
SQL>
******************************************************************************
REM David L. Hunt (file author) distributes this and other
REM files/scripts for educational purposes only, to illustrate the
REM use or application of various computing techniques. Neither the
REM author nor "Dasages, LLC" makes any warranty regarding this
REM script's fitness for any industrial application or purpose nor is
REM there any claim that this or any similarly-distributed scripts
REM are error free or should be used for any purpose other than
REM illustration.
REM
REM Please contact the author via email (dave@dasages.com) when
REM you have comments, suggestions, and/or difficulties with this
REM package or its functions.
REM
REM [Please keep the above disclaimer and the embedded electronic
REM documentation with this script.]
REM ******************************************************************************
create or replace procedure drop_obj (obj_type varchar2, obj_name varchar2) is
SQL_stm varchar2(100);
bad_SQL exception;
pragma exception_init(bad_SQL,-933);
-- applies to attemting to drop 'TABLE PARTITION','INDEX PARTITION',
no_table_view exception;
pragma exception_init(no_table_view,-942);
no_cluster exception;
pragma exception_init(no_cluster,-943);
bad_drop exception;
pragma exception_init(bad_drop,-950);
-- applies to attempting to drop 'CONSUMER GROUP','EVALUATION CONTEXT',
-- 'LOB','QUEUE','RESOURCE PLAN'
no_index exception;
pragma exception_init(no_index,-1418);
no_synonym exception;
pragma exception_init(no_synonym,-1434);
no_dblink exception;
pragma exception_init(no_dblink,-2024);
no_sequence exception;
pragma exception_init(no_sequence,-2289);
no_object exception;
pragma exception_init(no_object,-4043);
-- applies to attempting to drop 'FUNCTION','LIBRARY','PACKAGE BODY',
-- 'PACKAGE','PROCEDURE','TYPE BODY','TYPE'
no_trigger exception;
pragma exception_init(no_trigger,-4080);
no_operator exception;
pragma exception_init(no_operator,-29807);
begin
SQL_stm := 'drop '||obj_type||' '||obj_name;
execute immediate SQL_Stm;
exception
when no_table_view or no_cluster or no_index or no_synonym or no_dblink
or no_sequence or no_object or no_trigger or no_operator then
null;
when bad_sql or bad_drop then
raise;
when others then
raise;
end;
/