I would like to insert a value into a column depending on the value of another column in the same table.
For this I created the following trigger:
create or replace TRIGGER INSERT_COLUMN2_TBL1
BEFORE INSERT OR UPDATE ON TBL1
FOR EACH ROW
begin
:new.column1 := CASE
when :new.column1 LIKE 'REQUESTED' then
INSERT INTO tbl1 (column2)
VALUES ('REQUEST_PENDING');
when :new.column1 LIKE 'NOT_REQUESTED' then
INSERT INTO tbl1 (column2)
VALUES ('TEXT123');
end;
I am getting following errors:
PLS-00103: Encountered the symbol "INSERT" when expecting one of the following: ( - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> continue
PLS-00103: Encountered the symbol "ELSE"
I am not sure how I can reference columns from the same table I try to fire the trigger on. Can it be done like this or is there a better approach?