【发布时间】: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