sql - 如何使用触发器跟踪另一个表中的数字
问题描述
到目前为止我做了什么
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 语句中,但我不确定到底是什么问题
解决方案
你需要使用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;
推荐阅读
- android - Jetpack Compose 中的 TextClock 等价物是什么?
- python - Mongo 获取一组键,包括嵌套的,以及相关的最近看到的日期
- automation - 如何在 Tosca 工具中对空值进行逐行比较
- list - Flutter:列表已弃用?
- vue.js - PrimeVue:表格列对齐不一致
- kotlin - 当函数成功执行完成时如何让 Kotlin “监听”
- ssrs-2012 - SSRS 报告 - 在报告中将 css/html/xml 格式字段显示为字符串或简单文本
- c# - 无法加载对象列表(
- ) 到 firebase 实时数据库
- python - 调整 QSplitter 的大小不尊重 QSizePolicy 或 setStretchFactor?
- python - 如何从模块函数中获取特定输出?