【发布时间】:2019-03-14 02:57:19
【问题描述】:
create or replace trigger trg_t3 after
insert OR update or delete of salary on t2
for each row
begin
if
to_char(systimestamp,'hh24') not between 9 and 17
then
insert into t3 values (:new.salary, :old.salary, sysdate);
else
DBMS_OUTPUT.put_line ('update is not possible between 9:00 and 17:00');
end if;
end;
/
这将根据表t2 上的触发器中提到的条件插入旧工资、新工资和表t3 上的时间。但我需要更新或删除工资的员工姓名。
如果我要更新t2 的工资,我需要将我已修改其工资的特定员工的姓名插入t3。但是当前方法只会插入旧工资,新工资和时间
这里是创建表格的代码
create table t2 ( name varchar(20), salary varchar2(20));
create table t3 (salary_new varchar2(50), salary_old varchar2(20), log_date date);
insert all
into t2 values('hari',2000)
into t2 values('sam',40000)
into t2 values('ravi',60000)
into t2 values('manoj',8000)
into t2 values('pratheep',10000)
into t2 values('john',3000)
into t2 values('joe',50000)
into t2 values('scott',70000)
select * from dual;
【问题讨论】:
标签: oracle plsql database-trigger