Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading