今天遇到一个有意思的小问题,一同事有这样一个需求:在更新表T时,如果只是更新字段C,那么不希望触发该该表的触发器去处理业务逻辑.即想在触发器中做出判断:如果更新了字段C,那么跳出触发器,不处理业务逻辑,如果是更新其它字段,那么让触发器去处理业务逻辑. 他是这样做的 1: if :NEW.C != :OLD.C then 2: return; 3: end if; 但是这样有一个问题:更新不一定值有变化.当更新的值有变化时,它很好的实现了业务逻辑,但是如果更新的值没有变化,那
有这么一张表: create table hy_testtime( id number(6,0) not null primary key, name nvarchar2(20) not null, utime timestamp(6) ) 如果这样给它充值: insert into hy_testtime select rownum, dbms_random.string('*',dbms_random.value(1,20)), sysdate from dual connect by le
oracle触发器加条件判断,如果某个字段,isnode=0,那么不执行下面的方法,数据如下: create or replace trigger tr_basestation_insert_emp before insert on BJLT.BASESTATION REFERENCING NEW AS new_val OLD AS old_val --在这里设置名字,然后可引用新值,旧值 for each row ) declare --local variables here begin i
SQL Server 1创建触发器 GO BEGIN IF (object_id('WMY', 'tr') is not null) DROP trigger WMY END; GO CREATE TRIGGER WMY ON Student Instead of INSERT AS BEGIN INSERT INTO Student (number,name) VALUES (1205,'角色2'); END; --Begin 与end相当于{},是一个语句块,可有可无此处为演示所用 --ON