Check user name in a trigger
SQL>
SQL>
SQL> create table foo( a number );
Table created.
SQL>
SQL> create or replace trigger biud_foo
2 before insert or update or delete
3 on foo
4 begin
5 if user not in ( 'CLBECK', 'SDILLON' ) then raise_application_error( -20001,'You do not have access to modify this table.' );
6 end if;
7 end;
8 /
Trigger created.
SQL>
SQL> insert into foo (a) VALUES (1);
insert into foo (a) VALUES (1)
*
ERROR at line 1:
ORA-20001: You do not have access to modify this table.
ORA-06512: at "JAVA2S.BIUD_FOO", line 2
ORA-04088: error during execution of trigger 'JAVA2S.BIUD_FOO'
SQL>
SQL> drop table foo;
Table dropped.
SQL>
Related examples in the same category