日期:2014-05-16 浏览次数:21149 次
CREATE OR REPLACE TRIGGER TEST
BEFORE UPDATE OF name
ON tb FOR EACH ROW
DECLARE
L_USERNAME VARCHAR2(100);
BEGIN
SELECT T.USERNAME INTO L_USERNAME FROM USER_USERS T;
IF L_USERNAME = '011' THEN
DBMS_OUTPUT.PUT_LINE('YOU CAN NOT UPDATE THE COLUMN');
ROLLBACK;
END IF;
END;
create or replace trigger test_trig
before update on tb
declare
user varchar2(10);
begin
SELECT SYS_CONTEXT('USERENV','SESSION_USER') into user from dual;
if user='011 ' and updating('name') then
raise_application_error(-20001,'not allow change'
end if;
end;