【问题标题】:ORA-04088: error during execution of triggerORA-04088: 执行触发器期间出错
【发布时间】:2017-03-26 05:27:36
【问题描述】:

我面临以下问题。我在 Oracle 11g 第 2 版中使用以下 sql 创建了一个表:

create table loc_aud
(
username varchar2(20),
audittime date,
IP VARCHAR2(30),
locno number(4),
old_city number(4),
new_city number(4)
);

此表在 sys 架构中。然后我在 sys 架构中使用以下命令创建了一个用于价值基础审计的触发器

CREATE OR REPLACE TRIGGER location_audit    
AFTER UPDATE OF city    
ON hr.locations     
REFERENCING NEW AS NEW OLD AS OLD     
FOR EACH ROW  
BEGIN 
IF :old.city != :new.city THEN
     INSERT INTO loc_aud  
     VALUES (user, sysdate, UTL_INADDR.get_host_address,
     :new.location_id,:old.city,:new.city);
  END IF; 
END;

之后,我连接了 hr 架构并尝试使用以下命令更新 city 列:

update locations set city = 'Dhaka' where location_id = 2100;

但它给了我以下错误

update locations set city = 'Dubai' where location_id = 2100
       *
ERROR at line 1:
ORA-01722: invalid number
ORA-06512: at "SYS.LOCATION_AUDIT", line 3
ORA-04088: error during execution of trigger 'SYS.LOCATION_AUDIT'

我做错了什么?

【问题讨论】:

  • 将其添加为答案并接受它

标签: oracle oracle11g audit database-trigger


【解决方案1】:

我创建的名为loc_aud 的表有错误的数据类型。 city 列是 varchar2,我试图在其中保存的是 number 数据类型。我改变了表格,它起作用了。

【讨论】:

    猜你喜欢
    • 2013-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-06
    • 2013-10-14
    相关资源
    最近更新 更多