^`
END IF; END; UPDATE emp SET sal=800 WHERE empno=7876; UPDATE emp SET sal=450 WHERE empno=7876; COMMIT; SELECT empno,ename,job,sal FROM emp WHERE empno=7876; ^`
【练习3】限定对emp表的修改,只能修改部门10的雇员工资。 CREATE OR REPLACE TRIGGER CHECK_NO BEFORE UPDATE ON emp FOR EACH ROW BEGIN IF :new.DEPTNO<>10 THEN RAISE_APPLICATION_ERROR(-20001, '修改的部门不符,操作取消!'); END IF; END; ^`
UPDATE emp SET sal=8000 WHERE deptno=20; UPDATE emp SET sal=6789 WHERE deptno=30; UPDATE emp SET sal=888 WHERE deptno=10; select * from emp; ^`
【训练4】 CREATE TRIGGER CASCADE_UPDATE AFTER UPDATE OF deptno ON DEPT FOR EACH ROW BEGIN UPDATE EMP SET EMP.DEPTNO=:NEW.DEPTNO WHERE EMP.DEPTNO=:OLD.DEPTNO; END; ^`
UPDATE dept SET deptno=11 WHERE deptno=10; COMMIT; SELECT empno,ename,deptno FROM emp;