Home > database >  create trigger for IF condition in oracle
create trigger for IF condition in oracle

Time:06-17

I have created a trigger which inserts City as Others for all the data inserted with City name OTHERS

But it updates as null for text other than OTHERS. So I want to add IF condition for the same. Below is my trigger.

create or replace TRIGGER TGR_UPD_OTHERS_TVIPL
   BEFORE INSERT OR UPDATE ON IPCOLO_IPFEE_CALC_MST
FOR EACH ROW
 BEGIN
     new.CITY := case :NEW.CITY
                     when 'OTHERS' THEN 'Others'
                     end;
END;

CodePudding user response:

That's because you didn't say what to do "else":

:new.city := case when :new.city = 'OTHERS' then 'Others'
                  else :new.city
             end;
  • Related