Trigger to Prevent Dropping Objects

This trigger secures objects, preventing a user from dropping them by mistake. To begin, create a table for the example below called secured_objects with a column objectname, with datatype varchar2(20). Insert a record into this table with a value, the name of the object, which should not get dropped. Then, create the following trigger:


create or replace trigger check_beforedrop
before drop on database
declare
  oname char(20);
begin
  select objectname into oname from secured_objects 

  where upper(objectname)=ora_dict_obj_name;
  if sql%found then
    RAISE_APPLICATION_ERROR(-20001,'You did not want this object to be dropped');
  end if;
exception
  when no_data_found
  then dbms_output.put_line('This object will be dropped');
end;

After this trigger is created, you cannot drop an object whose name is entered in the table. In the case where you need to drop an object, remove the entry from the secured_objects table.

Author Profile

sysdba ;

Other posts by sysdba

Author's web site



Are you satisfied with this blog?
Why not subscribe our RSS Feed? you will always get the latest post.


1 Comment

  1. Каталог статей

    Remarkable topic

    1

Leave A Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>




3 visitors online now
3 guests, 0 members
Max visitors today: 3 at 09:26 am CET
This month: 7 at 03-08-2010 09:18 pm CET
This year: 13 at 02-28-2010 05:55 am CET
All time: 14 at 12-23-2009 11:57 am CET