HEEN
HEEN

Reputation: 4721

create trigger for IF condition in oracle

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;

Upvotes: 0

Views: 104

Answers (1)

Littlefoot
Littlefoot

Reputation: 142705

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

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

Upvotes: 1

Related Questions