J
J
Jivax2020-11-16 14:47:21
Oracle
Jivax, 2020-11-16 14:47:21

How to implement a trigger that prevents the user from editing a table?

Hello! Help, please solve the problem. You need to write a trigger that uses an autonomous transaction, prohibits the user from editing table data and saves information about it in a special log. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2020-11-16
@Jivax

Such things need to be regulated by the rights to the table. For example:

GRANT INSERT, UPDATE, DELETE ON schema.tablename TO  username; --Дать права
REVOKE INSERT, UPDATE, DELETE ON schema.tablename FROM username; --Отозвать права

upd
Writing in a special journal will be homework.
create or replace trigger MY_TRIGGER_NAME
  before insert or update or delete
     on MY_TABLE_NAME
begin
  if user in ( 'BAD_USER', 'ANGRY_USER' ) then raise_application_error( -20001,'You do not have access to modify this table.' );
  end if;
end;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question