Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I create a table in my database. Now i need to block the drop operation for that table.. pls give some tips.

Thanks
Durga
Posted

1 solution

Hi

Please try this ....


CREATE TABLE security AS SELECT object_name, owner FROM dba_objects WHERE object_type='TABLE' ;

CREATE OR REPLACE TRIGGER trg_security BEFORE DROP ON DATABASE
DECLARE
v_object_name char(128);
v_owner varchar2(128);
BEGIN
SELECT object_name INTO v_object_name FROM security WHERE UPPER(object_name) = ora_dict_obj_name and owner = login_user;
IF SQL%FOUND THEN
RAISE_APPLICATION_ERROR(-20001,'Cannot drop protected table');
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL; -- Allows to drop that table
WHEN TOO_MANY_ROWS THEN
RAISE_APPLICATION_ERROR(-20002, 'Remove Duplicate entry from security table');
END;
 
Share this answer
 
Comments
durga.r 28-Sep-12 0:24am    
Sorry i cant understand your answer pls tell clearly
durga.r 28-Sep-12 0:25am    
I got syntax error for this query

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900