Mitul Karnik
Mitul Karnik

Reputation: 135

Error while creating a trigger

The following trigger will update the values of other column in the table for every insert made for the particular column, but somehow I'm getting the following error.

ORA-04084: cannot change NEW values for this trigger type

even the update statement did not seem to work in the trigger body;

create or replace trigger encode_trigger 
after insert on vulnerable_tags
for each row
declare 
  var1 varchar2(20);
  var2 varchar2(40);
begin
  var1 := :OLD.tag_name;
  var2 := Encode12(var1);
  :NEW.ascii_tags := var2;
end;
/

Upvotes: 0

Views: 432

Answers (1)

johnny
johnny

Reputation: 2122

If you want to change the value in a column, you'd need to use a BEFORE INSER OR UPDATET trigger, not an AFTER INSERT OR UPDATE trigger.

create or replace trigger encode_trigger 
before insert on vulnerable_tags
for each row
declare 
var1 varchar2(20);
var2 varchar2(40);
begin
var1:= :OLD.tag_name;
var2:=Encode12(var1);
:NEW.ascii_tags:=var2;
end

do you need after for a specific reason?

Upvotes: 2

Related Questions