oracle - 为 shipping_status_af_update 创建 Oracle TRIGGERS
问题描述
我需要创建一个名为“shipment_status_af_update”的触发器,每当更新 shipping_status 表时就会触发该触发器。此触发器将在更新 shipping_status 详细信息后将名称和操作插入到表“status_log_history”中。受影响的日志表 status_log_history 中的操作名称为“After_Update_Shipment_Status”。
Hints:
Trigger name : shipment_status_af_update
Table name : status_log_history
Field names :name, action
Action : 'After_Update_Shipment_Status'.
Hint: Add / after the end statement
我的代码是:
CREATE or REPLACE TRIGGER shipment_status_af_update
AFTER UPDATE on shipment_status FOR EACH ROW declare
BEGIN
insert into status_log_history (name,action)
values(:new.name,'After_Update_Shipment_Status');
END;
/
结果:警告:触发器创建时出现编译错误。
解决方案
如果两个表都存在并且包含您在触发器中使用的名称,则代码编译:
SQL> create table shipment_status (name varchar2(20));
Table created.
SQL> create table status_log_history(name varchar2(20), action varchar2(30));
Table created.
SQL> create or replace trigger shipment_status_af_update
2 after update on shipment_status
3 for each row
4 declare
5 begin
6 insert into status_log_history (name, action)
7 values (:new.name, 'After_Update_Shipment_Status');
8 end;
9 /
Trigger created.
SQL>
推荐阅读
- c++ - 我应该在此代码中进行哪些更改以显示路线上每个节点的点?
- netlogo - PDG中的记忆效应
- python - 如何使用keras评估多类分类的结果?
- django - Django分离应用程序?
- css - Material.io 字体 arrow_right 未显示
- angular - Angular 6 HttpClient GET response not returning the custom headers
- opencart-3 - htaccess 使用 opencart 3 对我的网站造成了全面破坏
- python-3.x - 使用 open() 读取文件时如何修复 EOF 错误
- aws-xray - 有没有办法为 AWS X-Ray 检测 Web/Javascript/ReactJS 客户端?
- php - PHP Web 服务无法识别 Swift POST 请求