2016-11-11 1007 views
2

我正面臨以下問題。我在Oracle 11g第2版中創建了以下sql表:ORA-04088:執行觸發器期間出錯

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' 

我在做什麼錯?

+0

添加作爲答案並接受它 –

回答

0

我創建的名爲loc_aud的表具有錯誤的數據類型。 city列是varchar2,我試圖保存的是number數據類型。我改變了桌子,它工作。