oracle - Trigger creation on a table for inserting value in a column -
how create trigger insert value in column depending on combination of 3 other columns of same table of newly inserted row in table.
create or replace trigger execution_trigger after insert on jobs declare v_a varchar2(100); v_b varchar2(100); v_c varchar2(120); begin select category, method,tech v_a, v_b, v_c jobs if v_c = '10x' , v_b = '20x' , v_a = '30x' update jobs set execution = 1; else update jobs set execution = 2; end if ; null; end
;
i not able execute this...
you need before insert
trigger here:
create or replace trigger execution_trigger before insert on jobs each row begin if :new.category = '30x' , :new.method = '20x' , :new.tech = '10x' :new.execution := 1; else :new.execution := 2; end if; end;
test:
create table jobs (category varchar2(10), method varchar2(10), tech varchar2(10), execution number(5)); insert jobs (category, method, tech) values ('30x', '20x', '10x'); insert jobs (category, method, tech) values ('abc', 'def', 'ghi'); select * jobs; category method tech execution ---------- ---------- ---------- ---------- 30x 20x 10x 1 abc def ghi 2
Comments
Post a Comment