首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为shipment_status_af_update创建Oracle触发器

为shipment_status_af_update创建Oracle触发器
EN

Stack Overflow用户
提问于 2021-05-29 17:35:21
回答 1查看 46关注 0票数 0

我需要创建一个名为'shipment_status_af_update‘的触发器,该触发器在shipment_status表更新时触发。此触发器将在更新shipment_status详细信息后将名称和操作插入到表'status_log_history‘中。受影响的日志表status_log_history中的操作名称为'After_Update_Shipment_Status‘。

代码语言:javascript
复制
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

我的代码是:

代码语言:javascript
复制
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;
/

结果:警告:触发器创建时出现编译错误。

EN

回答 1

Stack Overflow用户

发布于 2021-05-30 00:59:47

如果这两个表都存在并且包含您在触发器中使用的名称,则代码将编译:

代码语言:javascript
复制
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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67749849

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档