create or replace trigger [email protected]@ before insert or update or delete on @[email protected] REFERENCING OLD AS old_emp NEW AS new_emp for each row begin --通过应用程序修改时,F_SYNC_UPDATE=null或F_SYNC_UPDATE=0,此时不需要更新F_SYNC_DATE 时间戳,也不需要记录删除记录 if (:new_emp.F_SYNC_UPDATE is null) or (:new_emp.F_SYNC_UPDATE = 0) then --插入和更新操作,更新时间戳F_SYNC_DATE=systimestamp和F_SYNC_UPDATE=null if INSERTING or UPDATING then select systimestamp, null into :new_emp.F_SYNC_DATE, :new_emp.F_SYNC_UPDATE from dual; end if; if INSERTING then --把新增加的记录插入到操作记录表 insert into DATA_SYNC_B_OPERATOR (t_name, o_type, o_date, VKEYS) values (‘@[email protected]‘, 1, systimestamp, @[email protected]); end if; if DELETING then --把删除记录的主键添加到操作记录表 insert into DATA_SYNC_B_OPERATOR (t_name, o_type, o_date, VKEYS) values (‘@[email protected]‘, 3, systimestamp, @[email protected]); end if; end if; end [email protected]@;
时间: 2024-12-28 10:03:15