Search code examples
oracle-databaseoracle11gauditdatabase-trigger

ORA-04088: error during execution of trigger


I am facing following problem. I created a table with following sql in Oracle 11g release 2:

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

This table is in sys schema. Then I created a trigger for value base auditing using following command in sys schema

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;

After that I connected with hr schema and tried to update the city column with following command:

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

But it is giving me following errors

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'

What am I doing wrong?


Solution

  • The table I created named loc_aud had a wrong datatype. The column city was varchar2 and what I tried to save in it was a number datatype. I altered the table and it worked.