首页 > 解决方案 > 如何使用触发器跟踪另一个表中的数字

问题描述

到目前为止我做了什么

create or replace trigger trigger_position
before insert or update of education
on JobApplication
for each row

begin

update education_tracker 
set total_application = total_application + 1
where JobApplication.education =  education_tracker.education_level;
end;

表:

create table education_tracker( 
education_level varchar2(20), 
total_application number
);


create table JobApplication(
job_id number,
applicant_name varchar2(100),
address varchar2(120),
postcode varchar2(8),
email varchar2(30),
mobile varchar2(11),
marital varchar2(20),
education varchar2(20),
position varchar2(100)
);

我认为问题出在 where 语句中,但我不确定到底是什么问题

标签: sqloracleoracle-sqldeveloper

解决方案


你需要使用NEW

create or replace trigger trigger_position
before insert or update of education
on JobApplication
for each row

begin

update education_tracker 
set total_application = total_application + 1
where :NEW.education =  education_tracker.education_level;
end;

推荐阅读